TextView width in Table layout android - android

In my application screen i'm using table layout.in the table row i have two textview.The width of second textview always going out of screen width.I tried wrap_content,match_parent but not getting how to resolve this.How can i set width to device screen layout width?
xml code-
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="#color/even" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical" >
<TableLayout
android:id="#+id/tableLayoutDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="#+id/namerow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
>
<TextView
android:id="#+id/nameText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:text="Name" />
<TextView
android:id="#+id/dname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:background="#android:color/black"
android:text="Name :"
android:textColor="#808080" />
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
Even after giving 100dp width to TextView its going outof screen

In your case column #0 is OK, so you just have to enable shrink (and stretch too if you like) for column #1:
<TableLayout ...
android:shrinkColumns="1"
android:stretchColumns="1" >
You can have a full explanation in the main documentation:
https://developer.android.com/reference/android/widget/TableLayout.html
Best regards

It may be Android Graphical layout issue. I checked your code in Android View Design. The TextView letters not going Beyond the layout. If you have doubt Set the BackGround to the Text view and see what happened?

use this code : work perfect(replace your code with this and modify as your choice)
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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" >
<LinearLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/include1"
android:layout_marginTop="20dp"
android:gravity="top"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="30dp"
android:orientation="horizontal"
android:weightSum="100" >
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="35dp"
android:layout_weight="50"
android:gravity="left"
android:text="Name"
android:textColor="#454545"
android:textSize="12sp" />
<TextView
android:id="#+id/tvfullname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="left"
android:text="sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss"
android:textColor="#454545"
android:textSize="12sp" />
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dip"
android:layout_marginBottom="6dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="6dp"
android:background="#e1e2dd" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="35dp"
android:layout_weight="50"
android:gravity="left"
android:text="Birthday"
android:textColor="#454545"
android:textSize="12sp" />
<TextView
android:id="#+id/tvbirth"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="left"
android:text=""
android:textColor="#454545"
android:textSize="12sp" />
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dip"
android:layout_marginBottom="6dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="6dp"
android:background="#e1e2dd" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="35dp"
android:layout_weight="50"
android:gravity="left"
android:text="Gender"
android:textColor="#454545"
android:textSize="12sp" />
<TextView
android:id="#+id/tvgender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="left"
android:text=""
android:textColor="#454545"
android:textSize="12sp" />
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dip"
android:layout_marginBottom="6dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="6dp"
android:background="#e1e2dd" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="35dp"
android:layout_weight="50"
android:gravity="left"
android:text="Mobile Number"
android:textColor="#454545"
android:textSize="12sp" />
<TextView
android:id="#+id/tvmobile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="left"
android:text=""
android:textColor="#454545"
android:textSize="12sp" />
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dip"
android:layout_marginBottom="6dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="6dp"
android:background="#e1e2dd" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="35dp"
android:layout_weight="50"
android:gravity="left"
android:text="Email Id"
android:textColor="#454545"
android:textSize="12sp" />
<TextView
android:id="#+id/tvemail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="left"
android:text="sjdhgvfkasvsjdgfjsgdfjhgskdjfgakjsgdflaghdfljashdgfljadgsfjahg"
android:textColor="#454545"
android:textSize="12sp" />
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dip"
android:layout_marginBottom="6dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="6dp"
android:background="#e1e2dd" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="35dp"
android:layout_weight="50"
android:gravity="left"
android:text="Location"
android:textColor="#454545"
android:textSize="12sp" />
<TextView
android:id="#+id/tvlocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="left"
android:text=""
android:textColor="#454545"
android:textSize="12sp" />
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="1dip"
android:layout_marginBottom="6dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="6dp"
android:background="#e1e2dd" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="35dp"
android:layout_weight="50"
android:gravity="left"
android:text="City"
android:textColor="#454545"
android:textSize="12sp" />
<TextView
android:id="#+id/tvcity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="left"
android:text=""
android:textColor="#454545"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
see this image :

Related

I have problem in my layout which i need that in bottom

I'm using Linear Layout as Parent layout and need a linear layout in the bottom of the page that i'll be using as a button.
All that i can use now is margin top to that linear layout which won't be the proper method. So i need help in implementing the layout to the bottom of the screen.
Or any recommendation of which layout that i need to use for the desired results.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#F0F0F0">
<LinearLayout
android:layout_margin="10dp"
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:textColor="#000000"
android:text="Customer contact details:"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:weightSum="2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textColor="#000000"
android:layout_weight="1"
android:text="Name:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_weight="1"
android:text="User Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow
android:layout_marginBottom="5dp"
android:weightSum="2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textColor="#000000"
android:layout_weight="1"
android:text="Email:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_weight="1"
android:text="user#gmail.com"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow
android:weightSum="2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textColor="#000000"
android:layout_weight="1"
android:text="Mobile:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_weight="1"
android:text="123456"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:text="DELIVERY TYPE"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_marginTop="10dp"
android:id="#+id/text"
android:layout_marginStart="20dp"
android:paddingEnd="10dp"
android:text="Note: Delivery fee will be added based on the delivery
address."
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_marginTop="10dp"
android:paddingTop="5dp"
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:text="Pickup"
android:textColor="#000000"
android:layout_marginStart="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="#+id/pickup_time"
android:text="Select pickup time"
android:textSize="12sp"
android:layout_marginBottom="5dp"
android:layout_marginStart="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:background="#D3D3D3"
android:layout_width="match_parent"
android:layout_height="1dp"/>
<TextView
android:text="Delivery"
android:layout_marginTop="5dp"
android:layout_marginStart="20dp"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="#+id/delivery_time"
android:text="Select delivery time"
android:textSize="12sp"
android:layout_marginBottom="5dp"
android:layout_marginStart="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<TextView
android:textColor="#000000"
android:layout_marginTop="10dp"
android:layout_marginStart="20dp"
android:id="#+id/payment_option"
android:text="PAYMENT OPTION"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_marginTop="10dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:layout_marginStart="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:text="Pay Online"
android:layout_marginStart="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:weightSum="1"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_weight="1"
android:text="DELIVERY ADDRESS"
android:textColor="#000000"
android:layout_marginStart="20dp"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<Button
android:layout_marginEnd="10dp"
android:padding="10dp"
android:id="#+id/add_address"
android:text="Add Address"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:background="#drawable/button_red"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="5dp"
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="2dp"/>
<TextView
android:text="Home"
android:textColor="#000000"
android:layout_marginStart="30dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:textColor="#000000"
android:layout_marginStart="30dp"
android:text="User Address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:padding="10dp"
android:weightSum="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#E22028">
<TextView
android:layout_weight="1"
android:gravity="center_horizontal"
android:textColor="#FFFFFF"
android:text="Continue"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<ImageView
android:src="#drawable/ic_navigate_next_black_24dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
for such complex view you should always go for constraint layout . They are really handy .
There are few things which you need to take care of , as from your code i can see lots of hard coded text and dimens , which turns out to be bad practice for any android developer . And even the naming conventions should be take a look on .
Here the guideline for naming convention we should follow for a long run in android .
https://github.com/ribot/android-guidelines/blob/master/project_and_code_guidelines.md
And for the constraint layout , you can use the below link to get better understanding.
https://android-developers.googleblog.com/2017/08/understanding-performance-benefits-of.html
https://blog.mindorks.com/android-constraint-layout
Always try to put your dimes in dimes.xml folder under res . Res < values < dimens.
Now coming to your questions , we can do this with constraint layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/constraint_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F0F0F0"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linear_customer_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="vertical"
android:padding="10dp"
app:layout_constraintEnd_toEndOf="#id/constraint_parent"
app:layout_constraintStart_toStartOf="#id/constraint_parent"
app:layout_constraintTop_toTopOf="#id/constraint_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Customer contact details:"
android:textColor="#000000" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:weightSum="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Name:"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="User Name" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:weightSum="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Email:"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="user#gmail.com" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Mobile:"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="123456" />
</TableRow>
</TableLayout>
</LinearLayout>
<TextView
android:id="#+id/text_delivery_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="20dp"
android:text="DELIVERY TYPE"
android:textColor="#000000"
app:layout_constraintEnd_toEndOf="#id/constraint_parent"
app:layout_constraintStart_toStartOf="#id/constraint_parent"
app:layout_constraintTop_toBottomOf="#+id/linear_customer_detail" />
<TextView
android:id="#+id/text_delivery_note"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingEnd="10dp"
android:text="Note: Delivery fee will be added based on the delivery
address."
android:textColor="#000000"
app:layout_constraintEnd_toEndOf="#id/text_delivery_type"
app:layout_constraintStart_toStartOf="#+id/text_delivery_type"
app:layout_constraintTop_toBottomOf="#+id/text_delivery_type" />
<LinearLayout
android:id="#+id/linear_pickup_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#FFFFFF"
android:orientation="vertical"
android:paddingTop="5dp"
app:layout_constraintEnd_toEndOf="#id/constraint_parent"
app:layout_constraintStart_toStartOf="#id/constraint_parent"
app:layout_constraintTop_toBottomOf="#+id/text_delivery_note">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="Pickup"
android:textColor="#000000" />
<TextView
android:id="#+id/pickup_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginBottom="5dp"
android:text="Select pickup time"
android:textSize="12sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#D3D3D3" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:text="Delivery"
android:textColor="#000000" />
<TextView
android:id="#+id/delivery_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginBottom="5dp"
android:text="Select delivery time"
android:textSize="12sp" />
</LinearLayout>
<TextView
android:id="#+id/payment_option"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="PAYMENT OPTION"
android:textColor="#000000"
app:layout_constraintEnd_toEndOf="#id/text_delivery_type"
app:layout_constraintStart_toStartOf="#id/text_delivery_type"
app:layout_constraintTop_toBottomOf="#+id/linear_pickup_view" />
<LinearLayout
android:id="#+id/linear_pay_online"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#FFFFFF"
android:paddingTop="5dp"
android:paddingBottom="5dp"
app:layout_constraintEnd_toEndOf="#id/constraint_parent"
app:layout_constraintStart_toStartOf="#id/constraint_parent"
app:layout_constraintTop_toBottomOf="#+id/payment_option">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="Pay Online" />
</LinearLayout>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:text="DELIVERY ADDRESS"
android:textColor="#000000"
app:layout_constraintBottom_toBottomOf="#id/add_address"
app:layout_constraintStart_toStartOf="#id/text_delivery_type"
app:layout_constraintTop_toTopOf="#id/add_address" />
<Button
android:id="#+id/add_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:background="#drawable/button_red"
android:padding="10dp"
android:text="Add Address"
android:textAllCaps="false"
android:textColor="#FFFFFF"
app:layout_constraintEnd_toEndOf="#id/text_delivery_type"
app:layout_constraintTop_toBottomOf="#+id/linear_pay_online" />
<View
android:id="#+id/view_divider"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="5dp"
android:background="#FFFFFF"
app:layout_constraintEnd_toEndOf="#id/constraint_parent"
app:layout_constraintStart_toStartOf="#id/constraint_parent"
app:layout_constraintTop_toBottomOf="#id/add_address" />
<TextView
android:id="#+id/text_home"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Home"
android:textColor="#000000"
app:layout_constraintEnd_toEndOf="#id/text_delivery_type"
app:layout_constraintStart_toStartOf="#id/text_delivery_type"
app:layout_constraintTop_toBottomOf="#id/view_divider" />
<TextView
android:id="#+id/text_user_address"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="User Address"
android:textColor="#000000"
app:layout_constraintEnd_toEndOf="#id/text_home"
app:layout_constraintStart_toStartOf="#id/text_home"
app:layout_constraintTop_toBottomOf="#+id/text_home" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#E22028"
android:padding="10dp"
android:weightSum="1"
app:layout_constraintBottom_toBottomOf="parent">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="Continue"
android:textColor="#FFFFFF" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_navigate_next_black_24dp" />
</LinearLayout>
Hope this will be helpful . Happy coding .
You can use a Spacer view inside your LinearLayout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#F0F0F0">
<!-- Top View -->
<View
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!-- Vertical Spacer -->
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<!-- Bottom View -->
<View
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
The vertical spacer will fill the screen between your top and bottom views.
try this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F0F0F0">
<!-- You can also use a button with 'android:drawableEnd="#drawable/ic_navigate_next_black_24dp" -->
<!-- instead of this LinearLayout'-->
<LinearLayout
android:id="#+id/layout_bottom_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#E22028"
android:gravity="center"
android:padding="10dp"
android:weightSum="1">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="Continue"
android:textColor="#FFFFFF" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_navigate_next_black_24dp" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/layout_bottom_btn"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#F0F0F0"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#FFFFFF"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Customer contact details:"
android:textColor="#000000" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:weightSum="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Name:"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="User Name" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:weightSum="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Email:"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="user#gmail.com" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Mobile:"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="123456" />
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:text="DELIVERY TYPE"
android:textColor="#000000" />
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:paddingEnd="10dp"
android:text="Note: Delivery fee will be added based on the deliveryaddress."
android:textColor="#000000" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#FFFFFF"
android:orientation="vertical"
android:paddingTop="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="Pickup"
android:textColor="#000000" />
<TextView
android:id="#+id/pickup_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginBottom="5dp"
android:text="Select pickup time"
android:textSize="12sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#D3D3D3" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="5dp"
android:text="Delivery"
android:textColor="#000000" />
<TextView
android:id="#+id/delivery_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginBottom="5dp"
android:text="Select delivery time"
android:textSize="12sp" />
</LinearLayout>
<TextView
android:id="#+id/payment_option"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:text="PAYMENT OPTION"
android:textColor="#000000" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#FFFFFF"
android:paddingTop="5dp"
android:paddingBottom="5dp">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="Pay Online" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_weight="1"
android:text="DELIVERY ADDRESS"
android:textColor="#000000" />
<Button
android:id="#+id/add_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:background="#drawable/button_red"
android:padding="10dp"
android:text="Add Address"
android:textAllCaps="false"
android:textColor="#FFFFFF" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="5dp"
android:background="#FFFFFF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:text="Home"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="30dp"
android:text="User Address"
android:textColor="#000000" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
I used RelativeLayout as parent in your layout and as Tim Castelijns commented, yes you have to use ConstraintLayout for better and responsive user interface.
your layout has toomany hierarchy element , use constraint layout instead, however in LinearLayout you can add view with weight 1 and height 0 like i added in your layout
**<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#F0F0F0">
<LinearLayout
android:layout_margin="10dp"
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:textColor="#000000"
android:text="Customer contact details:"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:weightSum="2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textColor="#000000"
android:layout_weight="1"
android:text="Name:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_weight="1"
android:text="User Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow
android:layout_marginBottom="5dp"
android:weightSum="2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textColor="#000000"
android:layout_weight="1"
android:text="Email:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_weight="1"
android:text="user#gmail.com"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow
android:weightSum="2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:textColor="#000000"
android:layout_weight="1"
android:text="Mobile:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_weight="1"
android:text="123456"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:text="DELIVERY TYPE"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:layout_marginTop="10dp"
android:id="#+id/text"
android:layout_marginStart="20dp"
android:paddingEnd="10dp"
android:text="Note: Delivery fee will be added based on the delivery
address."
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_marginTop="10dp"
android:paddingTop="5dp"
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:text="Pickup"
android:textColor="#000000"
android:layout_marginStart="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="#+id/pickup_time"
android:text="Select pickup time"
android:textSize="12sp"
android:layout_marginBottom="5dp"
android:layout_marginStart="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:background="#D3D3D3"
android:layout_width="match_parent"
android:layout_height="1dp"/>
<TextView
android:text="Delivery"
android:layout_marginTop="5dp"
android:layout_marginStart="20dp"
android:textColor="#000000"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="#+id/delivery_time"
android:text="Select delivery time"
android:textSize="12sp"
android:layout_marginBottom="5dp"
android:layout_marginStart="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<TextView
android:textColor="#000000"
android:layout_marginTop="10dp"
android:layout_marginStart="20dp"
android:id="#+id/payment_option"
android:text="PAYMENT OPTION"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_marginTop="10dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:layout_marginStart="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:text="Pay Online"
android:layout_marginStart="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:weightSum="1"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_weight="1"
android:text="DELIVERY ADDRESS"
android:textColor="#000000"
android:layout_marginStart="20dp"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<Button
android:layout_marginEnd="10dp"
android:padding="10dp"
android:id="#+id/add_address"
android:text="Add Address"
android:textAllCaps="false"
android:textColor="#FFFFFF"
android:background="#drawable/button_red"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="5dp"
android:background="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="2dp"/>
<TextView
android:text="Home"
android:textColor="#000000"
android:layout_marginStart="30dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:textColor="#000000"
android:layout_marginStart="30dp"
android:text="User Address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<LinearLayout
android:padding="10dp"
android:weightSum="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#E22028">
<TextView
android:layout_weight="1"
android:gravity="center_horizontal"
android:textColor="#FFFFFF"
android:text="Continue"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<ImageView
android:src="#drawable/ic_navigate_next_black_24dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>**
replace LinearLayout with relative layout and create sub-parent linear layout and put your views inside it and then make it alignparent bottom make sure you have gave sub-parent layout height to wrap content
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--put your layout inside it-->
</LinearLayout>

Contents in ListView not centered

My app retrieves user details from DB and displays in the ListView. However the contents displayed in the ListView are not formatted properly.
This is how my layout is currently rendered:
This is my layout file for the activity:
<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="#000000"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
tools:context=".LeaderBoard" >
<LinearLayout
android:id="#+id/column"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/column_header1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:text="#string/strLBoardHeaderRank"
android:textColor="#f00"
android:textSize="24sp" />
<TextView
android:id="#+id/column_header2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:text="#string/strLBoardHeaderName"
android:layout_gravity="center"
android:textColor="#f00"
android:textSize="24sp" />
<TextView
android:id="#+id/column_header3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:text="#string/strLBoardHeaderScore"
android:textColor="#f00"
android:textSize="24sp" />
</LinearLayout>
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/column" >
</ListView>
</RelativeLayout>
The layout file for the list activity is below:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000" >
<TextView
android:id="#+id/rank"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:textColor="#f00"
android:textSize="20sp" />
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:textColor="#f00"
android:textSize="20sp" />
<TextView
android:id="#+id/score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:textColor="#f00"
android:textSize="20sp" />
</LinearLayout>
add android:gravity="center" for all textviews and layout file for the list activity textviews width should be 0dp because of weight property and u should also add android:orientation="horizontal"
<TextView
android:id="#+id/column_header1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:gravity="center"
android:text="strLBoardHeaderRank"
android:textColor="#f00"
android:textSize="24sp" />
<TextView
android:id="#+id/column_header2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:gravity="center"
android:text="strLBoardHeaderName"
android:layout_gravity="center"
android:textColor="#f00"
android:textSize="24sp" />
<TextView
android:id="#+id/column_header3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:gravity="center"
android:text="strLBoardHeaderScore"
android:textColor="#f00"
android:textSize="24sp" />
layout file for the list
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:orientation="horizontal" >
<TextView
android:id="#+id/rank"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:gravity="center"
android:textColor="#f00"
android:textSize="20sp" />
<TextView
android:id="#+id/name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:gravity="center"
android:textColor="#f00"
android:textSize="20sp" />
<TextView
android:id="#+id/score"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:gravity="center"
android:textColor="#f00"
android:textSize="20sp" />
</LinearLayout>
Try this one, this worked for me
//Main Layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:orientation="horizontal" >
<TableLayout
android:id="#+id/add_rule_table"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:layout_marginTop="5dp"
android:background="#color/list_divider"
android:orientation="vertical"
android:stretchColumns="*"
android:visibility="gone" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/list_divider"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/list_divider"
android:ems="4"
android:gravity="center"
android:text="#string/rule_no"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/list_divider"
android:ems="4"
android:gravity="center"
android:text="#string/lot"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/list_divider"
android:ems="4"
android:gravity="center"
android:text="#string/discount"
android:textSize="12sp"
android:textStyle="bold" />
</TableRow>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#color/list_divider" />
</TableLayout>
<ListView
android:id="#+id/rule_list_view"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_weight="1"
android:background="#android:color/transparent"
android:cacheColorHint="#00000000"
android:choiceMode="none"
android:listSelector="#android:color/transparent" />
</LinearLayout>
//Custom List View Items
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
>
<TableLayout
android:id="#+id/add_rule_table"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:layout_marginTop="5dp"
android:background="#color/white"
android:orientation="vertical"
android:stretchColumns="*" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:orientation="horizontal" >
<TextView
android:id="#+id/rule_nos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:layout_marginRight="1dp"
android:ems="3"
android:gravity="center_horizontal"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="1"
android:textSize="12sp" />
<TextView
android:id="#+id/lots"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="4"
android:gravity="center"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="23"
android:textSize="12sp" />
<TextView
android:id="#+id/discount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="4"
android:gravity="center"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="34%"
android:textSize="12sp" />
<TextView
android:id="#+id/edit_rule"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/edit_rule"
android:ems="4"
android:gravity="center_horizontal"
android:text="#string/edit"
android:textColor="#ffffff"
android:textSize="12sp" />
<TextView
android:id="#+id/delete_rule"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:background="#drawable/delete_rule"
android:ems="4"
android:gravity="center_horizontal"
android:text="#string/delete"
android:textColor="#ffffff"
android:textSize="12sp" />
</TableRow>
</TableLayout>
</LinearLayout>

how to add footer in given in android

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00b9e8"
android:orientation="vertical" >
<!-- <include layout="#layout/header" /> -->
<LinearLayout
android:id="#+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:background="#ffffff"
android:gravity="center"
android:padding="5dp" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Search Status"
android:textColor="#0060a4"
android:textSize="#dimen/font_15dp" />
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="1" />
<ImageView
android:id="#+id/setting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/settings" />
<ImageView
android:id="#+id/searchstatus_imgBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/back_icon" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="40dp" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.35"
android:background="#drawable/round_bg"
android:padding="10dp" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Status"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#0060a4"
android:textSize="20dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_weight="0.65"
android:background="#drawable/round_bg"
android:gravity="center"
android:padding="8dp" >
<TextView
android:id="#+id/status"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:gravity="center"
android:text="Accepted"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#0060a4"
android:textSize="20dp" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="40dip"
android:layout_height="40dip"
android:paddingLeft="25dip" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="40dp" >
<LinearLayout
android:id="#+id/linearlayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.35"
android:background="#drawable/round_bg"
android:padding="10dp" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Reason"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#0060a4"
android:textSize="20dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearlayout2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_weight="0.65"
android:background="#drawable/round_bg"
android:gravity="center"
android:padding="10dp" >
<TextView
android:id="#+id/reason"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#0060a4"
android:textSize="20dp" />
</LinearLayout>
</LinearLayout>
</LinearLayot>
This is my code i want to add one Footer but i am unable to do this i dont know why this Problem is coming even i have take relative layout then also its not working please tell me how add one footer plz Help
Try this method and better to use relative layout for 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_alignParentTop="true"
android:layout_above="#+id/footer"
android:id="#+id/content"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#999"
android:layout_margin="4dp"
>
<TextView
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Content"
android:gravity="center"
android:padding="20dp"
android:textColor="#fff"
/>
</LinearLayout>
<LinearLayout
android:layout_alignParentBottom="true"
android:id="#+id/footer"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="FOOTER"
android:gravity="center"
android:padding="20dp"
android:textColor="#fff"
android:background="#666"
/>
</LinearLayout>
</RelativeLayout>
this will give like this .is that you want ?

How to create a form that have autolookup in Android

I want to use auto look up for searching .
I have partially created this layout . This is my XML code.
Now how can i use autol lookup in this?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:src="#drawable/logo_demo" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView1"
android:layout_marginTop="10dp"
android:background="#drawable/flight_bar"
android:orientation="horizontal" >
<TextView
android:id="#+id/roundtripTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="23dp"
android:layout_marginTop="5dp"
android:layout_weight="0.01"
android:text="Round trip"
android:textColor="#android:color/white" />
<TextView
android:id="#+id/OneWayTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="23dp"
android:layout_marginTop="5dp"
android:layout_weight="0.01"
android:text="OneWay"
android:textColor="#android:color/white" />
<TextView
android:id="#+id/multicityTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="23dp"
android:layout_marginTop="5dp"
android:layout_weight="0.03"
android:text="MultiCity"
android:textColor="#android:color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:id="#+id/linearLayout4"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout1"
android:background="#drawable/from2"
android:orientation="horizontal" >
<TextView
android:id="#+id/fromTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="7dp"
android:layout_weight=".05"
android:text="From" />
<TextView
android:id="#+id/toTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="7dp"
android:layout_weight=".05"
android:text="To" />
</LinearLayout>
</RelativeLayout>
i have to use a auto look up box same below to the to i have to use autolook up and in the middle of both there will be image .So i have done till from and to part now i am not able to create to separate auto look up box below from and to.
Try this layout.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/imageView1"
android:layout_marginTop="10dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/roundtripTextView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="#FF0000FF"
android:gravity="center"
android:text="Round trip"
android:textColor="#android:color/white"
android:textSize="20sp" />
<TextView
android:id="#+id/OneWayTextView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="1dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="#FF0000FF"
android:gravity="center"
android:text="OneWay"
android:textColor="#android:color/white"
android:textSize="20sp" />
<TextView
android:id="#+id/multicityTextView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="1dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:background="#FF0000FF"
android:gravity="center"
android:text="MultiCity"
android:textColor="#android:color/white"
android:textSize="20sp" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout1"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical" >
<EditText
android:id="#+id/fromTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:gravity="center_horizontal"
android:hint="From" />
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="LON"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="London Great Britain"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<ImageView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#android:color/darker_gray"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="vertical" >
<EditText
android:id="#+id/toTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:gravity="center_horizontal"
android:hint="To" />
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="DXB"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Dubai United Arab Emirates"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Edit
Put below layout after "from/to" layout.
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/linear3"
android:orientation="horizontal" >
<AutoCompleteTextView
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:gravity="bottom"
android:text="LON" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/darker_gray"
android:src="#drawable/ic_launcher" />
<AutoCompleteTextView
android:id="#+id/textView3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
android:gravity="bottom"
android:text="DXB" />
</LinearLayout>

Android audio player ui

this is my layout for audio player the problem is when resolution is high there is balck space vacant under the play and delete button which located at the bottom of the ui. what i do?
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="840dp"
android:background="#333134"
>
<LinearLayout
android:layout_marginTop="20dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
>
<TextView
android:paddingTop="10dp"
android:id="#+id/Rec_Timer_ID"
android:text="00:00"
android:textSize="70sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
<LinearLayout
android:layout_marginTop="40dp"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content">
<Button
android:id ="#+id/Button_record_sound"
android:background="#drawable/rec_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_marginTop="30dp"
>
<LinearLayout android:layout_height="20dp"
android:layout_width="30dp"
android:gravity="center_horizontal">
<View
android:id="#+id/View1"
android:background= "#ffffff"
android:layout_width="5dp"
android:layout_height="5dp"
android:layout_marginTop="5dp"
/>
</LinearLayout>
<TextView
android:id="#+id/Description"
android:textColor="#ffffff"
android:textStyle="bold"
android:textSize="13sp"
android:paddingLeft="6dip"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="top"
android:minLines="2"
android:maxLines="2"
/>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_marginTop="5dip"
>
<LinearLayout android:layout_height="20dp"
android:layout_width="30dp"
android:gravity="center_horizontal">
<View
android:id="#+id/View22"
android:background= "#ffffff"
android:layout_width="5dp"
android:layout_height="5dp"
android:layout_marginTop="5dp"
/>
</LinearLayout>
<TextView
android:id="#+id/Description2"
android:textColor="#ffffff"
android:textStyle="bold"
android:textSize="13sp"
android:paddingLeft="6dip"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:minLines="2"
android:maxLines="2"
/>
</LinearLayout>
</LinearLayout>
<ImageView
android:layout_marginTop="2dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/bar1"/>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:clickable="false"
android:orientation="horizontal">
<TextView
android:id="#+id/TimerStart"
android:text="00:00"
android:textSize="11sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<SeekBar
android:padding="7dp"
android:id="#+id/SeekBar01"
android:layout_width="245dip"
android:layout_height="wrap_content"
android:clickable="false"
android:focusable="false"
android:longClickable="false"
/>
<TextView
android:id="#+id/TimerStop"
android:text="00:00"
android:textSize="11sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:background="#drawable/br_12"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_marginBottom="1dp"
>
<Button
android:gravity="center_horizontal"
android:id ="#+id/Button_Play_Sound"
android:background="#drawable/play1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:gravity="center_horizontal"
android:visibility="invisible"
android:layout_width="8dp"
android:layout_height="wrap_content"
/>
<Button
android:gravity="center_horizontal"
android:id ="#+id/Button_Delete_Sound"
android:background="#drawable/trash"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
I've not done much android programming but have you thought about creating multiple UI's for different screen resolutions?
Supporting Multiple Screens

Categories

Resources