I need to align the Button of the background. I need the output like the attached image. Button all should have to be aligned to center of the Blue background not the Logo.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/feedback_bg" >
<RelativeLayout
android:id="#+id/Frame_title"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<View
android:id="#+id/background"
android:layout_width="match_parent"
android:layout_height="75dp"
android:background="#drawable/topbluebar_and" />
<ImageView
android:id="#+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/alrimal_top_logo" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_toRightOf="#id/logo"
android:text="adfadf" />
</RelativeLayout>
</RelativeLayout>
Hey checkout this if it helps you
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/holo_blue_bright" >
<RelativeLayout
android:id="#+id/Frame_title"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="#+id/background"
android:layout_width="match_parent"
android:layout_toRightOf="#+id/logo_linear"
android:layout_height="75dp"
android:gravity="center|center_vertical"
android:background="#android:color/white" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="adfadf" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<LinearLayout
android:id="#+id/logo_linear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="#+id/logo"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="#drawable/icon" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
check this out..Worked perfectly in my case
<RelativeLayout
android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:background="#drawable/topbluebar_and" >
<LinearLayout
android:id="#+id/loginLayout"
android:layout_width="50dp"
android:layout_height="70dp"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:background="#035125"
android:orientation="horizontal"
android:weightSum="1" >
<ImageView
android:id="#+id/loginImage"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:layout_marginLeft="13dp"
android:layout_weight=".3"
android:src="#drawable/login_header" />
</LinearLayout>
<LinearLayout
android:id="#+id/aboutLayout"
android:layout_width="wrap_content"
android:layout_height="70dp"
android:layout_centerInParent="true"
android:layout_toLeftOf="#+id/loginLayout"
android:orientation="horizontal"
android:weightSum="1" >
<ImageView
android:id="#+id/aboutImage"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:layout_margin="5dp"
android:layout_weight=".3"
android:src="#drawable/about" />
<TextView
android:id="#+id/aboutbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp"
android:layout_weight=".7"
android:text="#string/about"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#android:color/white" />
</LinearLayout>
<LinearLayout
android:id="#+id/syncLayout"
android:layout_width="wrap_content"
android:layout_height="70dp"
android:layout_centerInParent="true"
android:layout_toLeftOf="#+id/aboutLayout"
android:orientation="horizontal"
android:weightSum="1" >
<ImageView
android:id="#+id/syncImage"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:layout_margin="5dp"
android:layout_weight=".3"
android:src="#drawable/sync" />
<TextView
android:id="#+id/synbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp"
android:layout_weight=".7"
android:text="#string/sync"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#android:color/white" />
</LinearLayout>
<LinearLayout
android:id="#+id/historyLayout"
android:layout_width="wrap_content"
android:layout_height="70dp"
android:layout_centerInParent="true"
android:layout_toLeftOf="#+id/syncLayout"
android:orientation="horizontal"
android:weightSum="1" >
<ImageView
android:id="#+id/historyImage"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:layout_margin="5dp"
android:layout_weight=".3"
android:src="#drawable/history" />
<TextView
android:id="#+id/historybtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp"
android:layout_weight=".7"
android:text="#string/history"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#android:color/white" />
</LinearLayout>
<LinearLayout
android:id="#+id/resourcesLayout"
android:layout_width="wrap_content"
android:layout_height="70dp"
android:layout_centerInParent="true"
android:layout_toLeftOf="#+id/historyLayout"
android:orientation="horizontal"
android:weightSum="1" >
<ImageView
android:id="#+id/resourcesImage"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:layout_margin="5dp"
android:layout_weight=".3"
android:src="#drawable/resources" />
<TextView
android:id="#+id/resourcesbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp"
android:layout_weight=".7"
android:text="#string/resources"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#android:color/white" />
</LinearLayout>
</RelativeLayout>
<ImageView
android:id="#+id/logoImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="15dp"
android:src="#drawable/alrimal_top_logo" />
Related
I want to add scroll in my XML without editing the following code. Is there any way of adding it in the following XML? I tried by adding Scroll view and then linear view but it makes the view cut. Is there any way of making it better, I have searched other repository but I didn't find a solution.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Activity.BookSeatsActivity"
android:orientation="vertical"
android:weightSum="12"
>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="8"
android:gravity="center_horizontal"
android:layout_marginTop="20dp"
android:weightSum="5"
android:orientation="horizontal"
>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="3"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:id="#+id/wheel"
android:src="#drawable/mywheel"
android:layout_alignParentRight="true"
android:layout_marginTop="5dp"
android:layout_marginEnd="17dp"
/>
<GridView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/grid"
android:layout_marginTop="10dp"
android:layout_below="#+id/wheel"
android:padding="1dp"
android:numColumns="5"
/>
</RelativeLayout>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".4"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".6"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:layout_marginStart="10dp"
android:weightSum="3"
android:layout_marginEnd="10dp"
>
<LinearLayout
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="1"
android:weightSum="2"
android:orientation="horizontal"
>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_weight=".5"
android:src="#drawable/seat_open"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1.5"
android:gravity="center_vertical"
android:text="Available"
android:paddingStart="5dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="1"
android:weightSum="2"
android:orientation="horizontal"
>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_weight=".5"
android:src="#drawable/seat_booked"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1.5"
android:gravity="center_vertical"
android:paddingStart="5dp"
android:text="Unavailable"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="1"
android:weightSum="2"
android:orientation="horizontal"
>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_weight=".5"
android:src="#drawable/seat_selected"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1.5"
android:paddingStart="5dp"
android:gravity="center_vertical"
android:text="Selected"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginEnd="10dp"
android:orientation="horizontal"
android:layout_marginStart="10dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="Seat Selected : "
android:textSize="18dp"
android:padding="5dp"
android:paddingStart="10dp"
android:textColor="#android:color/black"
android:textStyle="bold"
android:fontFamily="#font/montserrat_regular"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/tv_seat_selected"
android:textStyle="bold"
android:textColor="#android:color/black"
android:textSize="18dp"
android:padding="5dp"
android:paddingStart="10dp"
android:gravity="center_vertical"
android:layout_marginTop="10dp"
/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_height="0dp"
android:layout_weight="1"
>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/bt_booking_details"
android:textStyle="bold"
android:textColor="#android:color/white"
android:textSize="17dp"
android:layout_margin="10dp"
android:text="Enter Booking Details"
android:fontFamily="#font/montserrat_regular"
android:background="#drawable/circular_button"
/>
</RelativeLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
Please use the below code snippet for the XML file and change the image view as per your needs.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="12"
tools:context=".MainActivity">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_weight="8"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:weightSum="5">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="3">
<ImageView
android:id="#+id/wheel"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_marginTop="5dp"
android:layout_marginEnd="17dp"
android:layout_marginRight="17dp"
android:src="#drawable/sports" />
<GridView
android:id="#+id/grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/wheel"
android:layout_marginTop="10dp"
android:numColumns="5"
android:padding="1dp" />
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".4" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_weight=".6"
android:orientation="horizontal"
android:weightSum="3">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_weight=".5"
android:src="#drawable/toys" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1.5"
android:gravity="center_vertical"
android:paddingStart="5dp"
android:paddingLeft="5dp"
android:text="Available" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_weight=".5"
android:src="#drawable/mobile" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1.5"
android:gravity="center_vertical"
android:paddingStart="5dp"
android:paddingLeft="5dp"
android:text="Unavailable" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="2">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_weight=".5"
android:src="#drawable/home" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1.5"
android:gravity="center_vertical"
android:paddingStart="5dp"
android:paddingLeft="5dp"
android:text="Selected" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:padding="5dp"
android:paddingStart="10dp"
android:paddingLeft="10dp"
android:text="Seat Selected : "
android:textColor="#android:color/black"
android:textSize="18dp"
android:textStyle="bold" />
<TextView
android:id="#+id/tv_seat_selected"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center_vertical"
android:padding="5dp"
android:paddingStart="10dp"
android:paddingLeft="10dp"
android:textColor="#android:color/black"
android:textSize="18dp"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_weight="1">
<Button
android:id="#+id/bt_booking_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="Enter Booking Details"
android:textColor="#android:color/white"
android:textSize="17dp"
android:textStyle="bold" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
Please try the following code, I just changed the scroll view to be match_parent for width and height and the linear layout to be match_parent for width& wrap_content for height.
Please note that this view won't scroll till you run it on a small screen device.
and please change the images as you need.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:weightSum="12">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="8"
android:gravity="center_horizontal"
android:layout_marginTop="20dp"
android:weightSum="5"
android:orientation="horizontal"
>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="3"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:id="#+id/wheel"
android:src="#drawable/ic_launcher_background"
android:layout_alignParentRight="true"
android:layout_marginTop="5dp"
android:layout_marginEnd="17dp"
/>
<GridView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/grid"
android:layout_marginTop="10dp"
android:layout_below="#+id/wheel"
android:padding="1dp"
android:numColumns="5"
/>
</RelativeLayout>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".4"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight=".6"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:layout_marginStart="10dp"
android:weightSum="3"
android:layout_marginEnd="10dp"
>
<LinearLayout
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="1"
android:weightSum="2"
android:orientation="horizontal"
>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_weight=".5"
android:src="#drawable/ic_launcher_background"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1.5"
android:gravity="center_vertical"
android:text="Available"
android:paddingStart="5dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="1"
android:weightSum="2"
android:orientation="horizontal"
>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_weight=".5"
android:src="#drawable/ic_launcher_background"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1.5"
android:gravity="center_vertical"
android:paddingStart="5dp"
android:text="Unavailable"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="1"
android:weightSum="2"
android:orientation="horizontal"
>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_weight=".5"
android:src="#drawable/ic_launcher_background"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_weight="1.5"
android:paddingStart="5dp"
android:gravity="center_vertical"
android:text="Selected"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginEnd="10dp"
android:orientation="horizontal"
android:layout_marginStart="10dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:text="Seat Selected : "
android:textSize="18dp"
android:padding="5dp"
android:paddingStart="10dp"
android:textColor="#android:color/black"
android:textStyle="bold"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/tv_seat_selected"
android:textStyle="bold"
android:textColor="#android:color/black"
android:textSize="18dp"
android:padding="5dp"
android:paddingStart="10dp"
android:gravity="center_vertical"
android:layout_marginTop="10dp"
/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_height="0dp"
android:layout_weight="1"
>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/bt_booking_details"
android:textStyle="bold"
android:textColor="#android:color/white"
android:textSize="17dp"
android:layout_margin="10dp"
android:text="Enter Booking Details"
android:background="#drawable/ic_launcher_background"
/>
</RelativeLayout>
</LinearLayout>
</ScrollView>
I'm debutant in android and I want to get an interface like this but I couldn't place my linearlayout interface
I tried to use a horizontal and a vertical linearlayout but it doesn't work
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"><TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="22sp"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:id="#+id/txt1"
android:text="AAAAAAAA"/><Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BE"
android:id="#+id/button1"/></LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:gravity="bottom">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="22sp"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:id="#+id/txt2"
android:text="RRRRRRR"/><LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="22sp"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:id="#+id/txt3"
android:text="JJJJJJJJJJ"/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="GO"
android:id="#+id/button2"/>
</LinearLayout>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Start"
android:id="#+id/button3"/>
</LinearLayout>
Can you help me to correct this code?
Try this code.Hope this helps you.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.7"
android:gravity="center_horizontal">
<TextView
android:id="#+id/txt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:text="AAAAAAAA"
android:textSize="22sp" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BE" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.2"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="#+id/txt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:layout_gravity="center_horizontal"
android:text="RRRRRRR"
android:textSize="22sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="horizontal">
<TextView
android:id="#+id/txt3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:text="JJJJJJJJJJ"
android:textSize="22sp" />
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="GO" />
</LinearLayout>
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="0.2"
android:layout_gravity="center_horizontal"
android:text="Start" />
</LinearLayout>
you can try this use RelativeLayout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/txt1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:gravity="center"
android:text="AAAAAAAA"
android:textSize="22sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/myl1"
android:gravity="center"
android:text="123465" />
<LinearLayout
android:id="#id/myl1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/button3"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="123465" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_weight="1"
android:text="Start" />
</LinearLayout>
<Button
android:id="#+id/button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Start" />
</RelativeLayout>
I want to Display a Column Chart horizontal.I mean I want to change this:
to this:
but I don't know which properties or function can achieve it.Hope someone could show me the specific code.Thanks!!!!
If you are looking for this type of layout and it should be scrollable from left to right
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Qualities and Criteria"
android:textAppearance="#style/TextAppearance.AppCompat.Medium" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_weight="0.2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Poor (0-50%)"
android:textAppearance="#style/TextAppearance.AppCompat.Medium" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_weight="0.2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Satisfactory (50-70%)"
android:textAppearance="#style/TextAppearance.AppCompat.Medium" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_weight="0.2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Good (70-80%)"
android:textAppearance="#style/TextAppearance.AppCompat.Medium" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_weight="0.2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Excellent (80-150%)"
android:textAppearance="#style/TextAppearance.AppCompat.Medium" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_weight="0.2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Marks"
android:textAppearance="#style/TextAppearance.AppCompat.Medium" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white"
android:text="Objective, Scope & Project Knowledge (15%)" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_Objective_poor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_Objective_satisfact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_Objective_good"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_Objective_excel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<EditText
android:id="#+id/et_object"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:hint="Marks" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white"
android:text="Project Significance & Contribution to Society (15%)" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_project_poor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_project_satis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_project_good"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_project_exce"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<EditText
android:id="#+id/et_project"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:hint="Marks" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white"
android:text="Utilization of Engineering/ Problem Solving Skills (20%)" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_utiliz_poor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_utiliz_satis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_utiliz_good"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_utiliz_excel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<EditText
android:id="#+id/et_util"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:hint="Marks" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white"
android:text="Relevancy & Accuracy (20%)" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_Relevancy_poor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_Relevancy_satisf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_Relevancy_good"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_Relevancy_excel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<EditText
android:id="#+id/et_relev"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:hint="Marks" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white"
android:text="Presentation Skills (10%)" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_presen_poor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_presen_satis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_presen_good"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<Button
android:id="#+id/button_presen_excel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="#color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="150dp"
android:layout_height="wrap_content">
<EditText
android:id="#+id/et_presen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:hint="Marks" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
<Button
android:id="#+id/button_Next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_margin="40dp"
android:background="#color/colorPrimaryDark"
android:text="Next" />
</LinearLayout>
</ScrollView>
While I didn't found properties or function but when I change this:
CategoricalAxis horizontalAxis = new CategoricalAxis();
chartView.setHorizontalAxis(horizontalAxis);
LinearAxis verticalAxis = new LinearAxis();
chartView.setVerticalAxis(verticalAxis);
to this:
CategoricalAxis horizontalAxis = new CategoricalAxis();
chartView.setVerticalAxis(horizontalAxis);
LinearAxis verticalAxis = new LinearAxis();
chartView.setHorizontalAxis(verticalAxis);
My problem has been solved.
https://www.youtube.com/watch?v=if9qBW_nIxM&feature=youtu.be
i am working on Scrolling effect like default android calling App in lollipop.but i am not able to get smoothness like in default app.i am posted a link please check it.This is what i have achieved .
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:ripple="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar_city_selection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/blue"
android:minHeight="?attr/actionBarSize"
android:visibility="gone"
app:popupTheme="#style/Theme.AppCompat.Light.DarkActionBar"
app:theme="#style/Toolbar" />
<LinearLayout
android:id="#+id/wrap_total_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/home_search_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="17dp"
android:layout_marginRight="5dp"
android:layout_toLeftOf="#+id/show_fav_ripple"
android:background="#drawable/searchview_rounded"
android:orientation="horizontal" >
<ImageView
android:id="#+id/search"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:scaleType="fitXY"
android:src="#drawable/search" />
<EditText
android:id="#+id/search_outlet_edittxt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="#ffffff"
android:cursorVisible="false"
android:hint="Search for outlets"
android:singleLine="true" />
<ImageView
android:id="#+id/menu_overlay_txt"
android:layout_width="25dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="5dp"
android:gravity="center_vertical"
android:src="#drawable/more" />
</LinearLayout>
<com.competent.groove.thegroove.utils.RippleView
android:id="#+id/show_fav_ripple"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="17dp"
app:rv_framerate="10"
app:rv_rippleDuration="400"
ripple:rv_type="rectangle"
ripple:rv_zoom="true" >
<ImageView
android:id="#+id/show_fav_txt"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="#drawable/star" />
</com.competent.groove.thegroove.utils.RippleView>
</RelativeLayout>
<LinearLayout
android:id="#+id/pp_seacrh_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="17dp"
android:layout_marginRight="17dp"
android:layout_marginTop="15dp"
android:background="#drawable/searchview_rounded"
android:orientation="horizontal"
android:visibility="gone"
>
<ImageView
android:id="#+id/pp_search_img"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:scaleType="fitXY"
android:src="#drawable/search" />
<EditText
android:id="#+id/pp_search_outlet_edittxt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="#ffffff"
android:cursorVisible="true"
android:hint="Search for outlets"
android:enabled="true"
android:focusable="true"
android:singleLine="true" />
<ImageView
android:id="#+id/pp_menu_overlay_txt"
android:layout_width="25dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="5dp"
android:gravity="center_vertical"
android:src="#drawable/more" />
</LinearLayout>
<com.competent.groove.thegroove.utils.RippleView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:rv_framerate="10"
app:rv_rippleDuration="400"
ripple:rv_type="rectangle"
ripple:rv_zoom="true" >
<TextView
android:id="#+id/select_city_txt"
android:layout_width="match_parent"
android:layout_height="38dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="17dp"
android:layout_marginRight="17dp"
android:layout_marginTop="15dp"
android:background="#drawable/city_selector_curve"
android:gravity="center"
android:text="I am in CHANDIGARH" />
</com.competent.groove.thegroove.utils.RippleView>
<LinearLayout
android:id="#+id/pp_main_fragment_header"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:background="#color/blue"
android:visibility="gone"
android:orientation="horizontal" >
<TextView
android:id="#+id/pp_top_header"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:gravity="center"
android:text="PARTY PARTNER"
android:textColor="#color/white"
android:textSize="20dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<com.google.samples.apps.iosched.ui.widget.SlidingTabLayout
android:id="#+id/sliding_tabs"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="#color/blue" />
<TextView
android:id="#+id/home_dots_txtview"
android:layout_width="wrap_content"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:background="#color/blue"
android:gravity="center"
android:paddingRight="8dp"
android:text="D"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/white" />
</LinearLayout>
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/header" />
</LinearLayout>
my requirement is
I have this layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="66dp"
android:layout_height="64dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:src="#drawable/office_girl" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<TextView
android:id="#+id/greetingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hi Boss,"
android:textStyle="bold" />
<TextView
android:id="#+id/dailyStatusTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="What to say if someone call?" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="90dp"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<!-- android:layout_gravity="center" -->
<EditText
android:id="#+id/suto_sms_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="3dp"
android:hint="Text"
android:inputType="textMultiLine"
android:lines="3" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/text_phone_status"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Phone Status"
android:layout_marginTop="3dp"
android:layout_marginLeft="5dp"
android:textSize="20sp" />
<Spinner
android:id="#+id/spinner_phone_status"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/text_busy_until"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="until"
android:layout_marginTop="3dp"
android:layout_marginLeft="5dp"
android:textSize="20sp" />
<Button
android:enabled="true"
android:id="#+id/button_set_date_and_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_marginLeft="30dp"
android:text="#string/set_time" />
<TextView
android:enabled="true"
android:id="#+id/text_date_and_time"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_marginLeft="40dp"
android:textSize="12sp"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_gravity="center_horizontal"
android:orientation="horizontal" >
<Button
android:id="#+id/button_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="#string/button_confirm" />
<Button
android:id="#+id/button_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_marginLeft="3dp"
android:text="#string/button_cancel" />
</LinearLayout>
</LinearLayout>
This is part of the output:
My question is how to align my Confirm and Cancel buttons (last part of the xml) to buttom of the screen?
I saw examples of how it can be done using relative layout, but my xml is quite big and i dont want to have to change it to relative layout as it will mean lots of work.
Thanks.
Try this code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.9"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="66dp"
android:layout_height="64dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<TextView
android:id="#+id/greetingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hi Boss,"
android:textStyle="bold" />
<TextView
android:id="#+id/dailyStatusTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="What to say if someone call?" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="90dp"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<!-- android:layout_gravity="center" -->
<EditText
android:id="#+id/suto_sms_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="3dp"
android:hint="Text"
android:inputType="textMultiLine"
android:lines="3" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/text_phone_status"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="3dp"
android:text="Phone Status"
android:textSize="20sp" />
<Spinner
android:id="#+id/spinner_phone_status"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/text_busy_until"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="3dp"
android:text="until"
android:textSize="20sp" />
<Button
android:id="#+id/button_set_date_and_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="3dp"
android:enabled="true"
android:text="set_time" />
<TextView
android:id="#+id/text_date_and_time"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginTop="3dp"
android:enabled="true"
android:textSize="12sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.025"
android:baselineAligned="true"
android:gravity="center"
android:orientation="horizontal" >
<Button
android:id="#+id/button_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="confirm" />
<Button
android:id="#+id/button_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="cancel" />
</LinearLayout>
And here your using lot of LinearLayouts but personally i recommend you to try out relativelayout
Use the android:layout_gravity="bottom" attribute on the buttons as well as their containing LinearLayout.
Add
android:layout_weight="1"
in second last LinearLayout and
android:layout_weight="0"
in last LinearLayout. Hope this work for you.
It's actually very easy to use the RelativeLayout, because you can be very smart about it. For example, wrap it around everything, so that your current parent linear layout will be the first child, end put the linear layout with the buttons at outside of the current parent with the parameter alignParentBottom
Please see this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="66dp"
android:layout_height="64dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:src="#drawable/plus" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<TextView
android:id="#+id/greetingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hi Boss,"
android:textStyle="bold" />
<TextView
android:id="#+id/dailyStatusTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="What to say if someone call?" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="90dp"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<!-- android:layout_gravity="center" -->
<EditText
android:id="#+id/suto_sms_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="3dp"
android:hint="Text"
android:inputType="textMultiLine"
android:lines="3" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/text_phone_status"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Phone Status"
android:layout_marginTop="3dp"
android:layout_marginLeft="5dp"
android:textSize="20sp" />
<Spinner
android:id="#+id/spinner_phone_status"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/text_busy_until"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="until"
android:layout_marginTop="3dp"
android:layout_marginLeft="5dp"
android:textSize="20sp" />
<Button
android:enabled="true"
android:id="#+id/button_set_date_and_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_marginLeft="30dp"
android:text="set_time" />
<TextView
android:enabled="true"
android:id="#+id/text_date_and_time"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_marginLeft="40dp"
android:textSize="12sp"
android:textStyle="bold"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal" >
<Button
android:id="#+id/button_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:text="confirm" />
<Button
android:id="#+id/button_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:layout_marginLeft="3dp"
android:text="cancel" />
</LinearLayout>
</RelativeLayout>