I'm trying to create the following View:
My XML:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="14dp"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/meals_line_shadow_left" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="0" >
<TableRow
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<TextView
android:id="#+id/textDate"
style="#style/MealWizard.BigText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="text"
android:textSize="16sp" />
<ImageButton
android:id="#+id/buttonDatePicker"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingRight="7dp"
android:paddingLeft="7dp"
android:background="#null"
android:src="#drawable/general_date_button_selector" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<TextView
android:id="#+id/textTime"
style="#style/MealWizard.BigText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="15:34"
android:textSize="24sp" />
<ImageButton
android:id="#+id/buttonTimePicker"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingRight="7dp"
android:paddingLeft="7dp"
android:background="#null"
android:src="#drawable/general_time_button_selector" />
</TableRow>
</TableLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/meals_line_shadow_right" />
</LinearLayout>
The problem is that I can't see the right imageView:
I need solve that without using absolute size (It works with absolute values).
I'll be happy for any suggestions for fixing or alternatives
The solution is simple:
<TableLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:stretchColumns="0" >
Related
I am new to Android.
I am trying to show a scrollable table.
The XML visualizer on Android Studio shows it fine, but my device is not showing it.
In my device, I can only see the first TextView(routine_heading).
What should I do to overcome this problem?
Below is the XML code I used
<?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" >
<TextView
android:id="#+id/routine_heading"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/routine_header"
android:textAppearance="?android:textAppearanceLarge"/>
<ScrollView
android:id="#+id/layout"
android:layout_height="wrap_content"
android:scrollbars="horizontal|vertical"
android:layout_width="match_parent"
android:layout_marginTop="8dip"
android:scrollbarStyle="outsideOverlay"
android:fillViewport="false">
<HorizontalScrollView
android:id="#+id/horizontalView"
android:layout_height="wrap_content"
android:scrollbars="horizontal|vertical"
android:layout_width="wrap_content"
android:layout_marginTop="5dip">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/tlGridTable"
android:stretchColumns="*">
<TableRow
android:layout_weight="1">
<TextView
android:background="#drawable/cell"
android:text=""
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"/>
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:background="#drawable/cell"
android:text="10-10:50"
android:padding="3dip"
android:layout_height="match_parent"
/>
<TextView
android:text="10:50-11:40"
android:background="#drawable/cell"
android:padding="3dip"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<TextView
android:background="#drawable/cell"
android:text="11:40-12:30"
android:padding="3dip"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
/>
<TextView
android:background="#drawable/cell"
android:text="12:30-1:20"
android:padding="3dip"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
/>
<TextView
android:background="#drawable/cell"
android:text="2:35-3:20"
android:padding="3dip"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
/>
<TextView
android:background="#drawable/cell"
android:text="3:20-4:00"
android:padding="3dip"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
/>
<TextView
android:background="#drawable/cell"
android:text="4:00-4:50"
android:padding="3dip"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
</TableRow>
</TableLayout>
</HorizontalScrollView>
</ScrollView>
</LinearLayout>
Problem is that you are Setting column size to stretch to its parent! where its parent is a HorizontalScrollView which has infinite width! Thus, It can't set its weight.
So, You need a to put your Table in a ScrollView (vertical) then inside the Table there is the HorizontalScrollView. Also, you need to add height m width attribute after changing it.
<?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" >
<TextView
android:id="#+id/routine_heading"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/routine_header"
android:textAppearance="?android:textAppearanceLarge"/>
<ScrollView
android:id="#+id/layout"
android:layout_height="wrap_content"
android:scrollbars="horizontal|vertical"
android:layout_width="match_parent"
android:layout_marginTop="8dip"
android:scrollbarStyle="outsideOverlay"
android:fillViewport="false">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/tlGridTable"
android:stretchColumns="*">
<HorizontalScrollView
android:id="#+id/horizontalView"
android:layout_height="wrap_content"
android:scrollbars="horizontal|vertical"
android:layout_width="wrap_content"
android:layout_marginTop="5dip">
<TableRow
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:background="#drawable/cell"
android:text=""
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"/>
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:background="#drawable/cell"
android:text="10-10:50"
android:padding="3dip"
android:layout_height="match_parent"
/>
<TextView
android:text="10:50-11:40"
android:background="#drawable/cell"
android:padding="3dip"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<TextView
android:background="#drawable/cell"
android:text="11:40-12:30"
android:padding="3dip"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
/>
<TextView
android:background="#drawable/cell"
android:text="12:30-1:20"
android:padding="3dip"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
/>
<TextView
android:background="#drawable/cell"
android:text="2:35-3:20"
android:padding="3dip"
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
/>
<TextView
android:background="#drawable/cell"
android:text="3:20-4:00"
android:padding="3dip"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
/>
<TextView
android:background="#drawable/cell"
android:text="4:00-4:50"
android:padding="3dip"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
/>
</TableRow>
</HorizontalScrollView>
</TableLayout>
</ScrollView>
</LinearLayout>
Recommended to use a ListView/RecyclerView with a adapter for this
kind of works.
If you want a scrolling table, you generally use a ListView + an Adapter.
Each item of the Adapter should create a "row" of the "table".
Using a RecyclerView could help with the vertical and horizontal scrolling.
Add Table layout below Scrollview (into child view) like this
<?xml version="1.0" encoding="utf-8"?>
<TableLayout 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/routine_heading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/app_name"
android:textAppearance="?android:textAppearanceLarge"
/>
<ScrollView
android:id="#+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dip"
android:fillViewport="false"
android:scrollbarStyle="outsideOverlay"
android:scrollbars="horizontal|vertical"
>
<TableLayout
android:id="#+id/tlGridTable"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*"
>
<HorizontalScrollView
android:id="#+id/horizontalView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:scrollbars="horizontal|vertical"
>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/ic_launcher"
android:text=""
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/ic_launcher"
android:padding="3dip"
android:text="10-10:50"
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/ic_launcher"
android:padding="3dip"
android:text="10:50-11:40"
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/ic_launcher"
android:padding="3dip"
android:text="11:40-12:30"
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/ic_launcher"
android:padding="3dip"
android:text="12:30-1:20"
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/ic_launcher"
android:padding="3dip"
android:text="2:35-3:20"
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/ic_launcher"
android:padding="3dip"
android:text="3:20-4:00"
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/ic_launcher"
android:padding="3dip"
android:text="4:00-4:50"
/>
</TableRow>
</HorizontalScrollView>
</TableLayout>
</ScrollView>
</TableLayout>
EDITED to improve specifics:
Hi, my layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:padding="10dp"
tools:context="${packageName}.${activityClass}" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="1"
android:text="Select Character"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff" />
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_below="#+id/textView1"
android:orientation="vertical"
android:paddingTop="10dp" >
<TextView
android:id="#+id/SelectedCharacterName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff" />
<TextView
android:id="#+id/TraitName1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Trait 1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#ffffff" />
etc...
</LinearLayout>
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0"
android:fillViewport="false"
android:paddingTop="10dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/Character1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#4a4a4a"
android:clickable="true"
android:gravity="center"
android:text="Character 1"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff" />
etc...
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/buttonConfirmCharacter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center"
android:text="#string/button_Confirm" />
</LinearLayout>
I am looking to make the scrollview fit the remaining space between the other elements however with this setup the scrollview doesn't seem to render at all. These settings are the result of looking for solutions and implementing weight.
An answer without java code would be preferential.
Thanks.
Here, this would works just fine
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text1" />
<TextView
android:id="#+id/SelectedCharacterName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:layout_marginTop="10dp" />
<TextView
android:id="#+id/TraitName1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Trait 1" />
etc...
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true"
android:paddingTop="10dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/Character1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:gravity="center"
android:text="Character 1" />
etc...
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/buttonConfirmCharacter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="#string/button_Confirm" /></LinearLayout>
I'm writing a catalog app for Android tablet, which displays 6 item per page: 3 items for each row.
Each item is composed by an image (200x300) and a text.
Designing with android xml layout editor in Eclipse everything seems fine, because I'm using a default image for each item and a dummy fixed text: each item is horizontally perfectly equidistant there.
When I run on tablet, each item is overwritten with an image taken from filesystem (200x300 again) and the text (variable length) is taken from database.
The problem is taht after the 6 elements are populated with my custom data, the layout seems disaligned, as you can see from this screenshot:
Probably (but I'm not sure) the problem is caused by the long text.
Is there a way (if the problem is the text) to force the layout to remain fixed? (Or make the font small dinamically (or trunc the text, I don't care))
This is the layout I'm using:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/RootView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/white"
android:gravity="center_horizontal|center_vertical"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/filaTop"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_margin="15dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:id="#+id/ivBottle1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/bottle_trans" />
<TextView
android:id="#+id/tvBottle1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|center"
android:text="vino"
android:textAlignment="center"
android:textSize="22sp" >
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:id="#+id/ivBottle2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/bottle_trans" />
<TextView
android:id="#+id/tvBottle2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|center"
android:text="vino"
android:textAlignment="center"
android:textSize="22sp" >
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:id="#+id/ivBottle3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/bottle_trans" />
<TextView
android:id="#+id/tvBottle3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|center"
android:text="vino"
android:textAlignment="center"
android:textSize="22sp" >
</TextView>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/filaBottom"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_margin="15dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:id="#+id/ivBottle4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/bottle_trans" />
<TextView
android:id="#+id/tvBottle4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|center"
android:text="vino"
android:textAlignment="center"
android:textSize="22sp" >
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:id="#+id/ivBottle5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/bottle_trans" />
<TextView
android:id="#+id/tvBottle5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|center"
android:text="vino"
android:textAlignment="center"
android:textSize="22sp" >
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:id="#+id/ivBottle6"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/bottle_trans" />
<TextView
android:id="#+id/tvBottle6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|center"
android:text="vino"
android:textAlignment="center"
android:textSize="22sp" >
</TextView>
</LinearLayout>
</LinearLayout>
Thanks in advance.
EDIT (SOLVED): putting android:layout_width="0dip" in each linear layout, solved the problem as Dale Wilson suggested, like this:
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
When you have layout_weight, start the views at 0px. The layout_weight will grow them all to the same size. If you say wrap_content then they start at different sizes, grow the same amounts, so they end up with different sizes.
Update your layout like below
<?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:id="#+id/RootView">
<LinearLayout android:layout_height="0dp"
android:layout_weight="1"
android:layout_width="match_parent"
android:id="#+id/filaTop">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#ff00ff"
android:orientation="vertical" >
<ImageView
android:id="#+id/ivBottle1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:background="#drawable/ic_launcher"
android:src="#drawable/bottle_trans" />
<TextView
android:id="#+id/tvBottle1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="top|center"
android:text="vino"
android:textAlignment="center"
android:textSize="22sp" >
</TextView>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:layout_centerInParent="true"
android:id="#+id/ivBottle2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher"
android:layout_gravity="center"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/bottle_trans" />
<TextView
android:layout_alignParentBottom="true"
android:id="#+id/tvBottle2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|center"
android:text="vino"
android:textAlignment="center"
android:textSize="22sp" >
</TextView>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#0000ff"
android:orientation="vertical" >
<ImageView
android:layout_centerInParent="true"
android:id="#+id/ivBottle3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/ic_launcher"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/bottle_trans" />
<TextView
android:layout_alignParentBottom="true"
android:id="#+id/tvBottle3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|center"
android:text="vino"
android:textAlignment="center"
android:textSize="22sp" >
</TextView>
</RelativeLayout>
</LinearLayout>
<LinearLayout android:layout_height="0dp"
android:layout_weight="1"
android:layout_width="match_parent"
android:id="#+id/filaBottom">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#ff00ff"
android:orientation="vertical" >
<ImageView
android:id="#+id/ivBottle4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:background="#drawable/ic_launcher"
android:src="#drawable/bottle_trans" />
<TextView
android:id="#+id/tvBottle4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="top|center"
android:text="vino"
android:textAlignment="center"
android:textSize="22sp" >
</TextView>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:layout_centerInParent="true"
android:id="#+id/ivBottle5"
android:layout_width="wrap_content"
android:background="#drawable/ic_launcher"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/bottle_trans" />
<TextView
android:layout_alignParentBottom="true"
android:id="#+id/tvBottle5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|center"
android:text="vino"
android:textAlignment="center"
android:textSize="22sp" >
</TextView>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#0000ff"
android:orientation="vertical" >
<ImageView
android:layout_centerInParent="true"
android:id="#+id/ivBottle6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/ic_launcher"
android:layout_weight="1"
android:adjustViewBounds="true"
android:src="#drawable/bottle_trans" />
<TextView
android:layout_alignParentBottom="true"
android:id="#+id/tvBottle6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top|center"
android:text="vino"
android:textAlignment="center"
android:textSize="22sp" >
</TextView>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
Also remove unnecessary lines of code.
Im trying to make something similar to this - Android Layout(User Interface) only I want to make the first column with a weight of 4 the second one with a weight of 2 (and also with two rows) and the last one with a weight of 1 (and also with three rows)...problem is It messes up itself (I copy and pasted the answer and changed everything according to my needs but it keeps on get messed up.. =) any help?
[code]
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/background_color"
android:orientation="vertical"
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="4"
android:gravity="center_horizontal|center_vertical"
android:orientation="horizontal" >
<TextView
android:id="#+id/textDishes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="#string/dishes"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imageDishes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="#dimen/seperator_size"
android:background="#color/seperator" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:measureWithLargestChild="true"
android:orientation="horizontal"
android:weightSum="2" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="#+id/textfood"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/food"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imagefood"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="#dimen/seperator_size"
android:background="#color/seperator" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="#+id/textMalls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/malls"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imageMalls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="#dimen/seperator_size"
android:background="#color/seperator" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:weightSum="3"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/app_name"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="#dimen/seperator_size"
android:background="#color/seperator" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/coupons"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="#dimen/seperator_size"
android:background="#color/seperator" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/markets"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
[/code]
That is the result -
The result should look like -
Any help??
EDIT working example now
This is not a complete answer because the vertical dividers are still not working, but hopefully it gets you going in the right direction:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/textDishes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dishes"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imageDishes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="#color/red" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/textfood"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Food"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imagefood"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<View
android:layout_width="5dp"
android:layout_height="fill_parent"
android:background="#color/red"
android:gravity="center" >
</View>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/textMalls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Malls"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imageMalls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="#color/red" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="App name"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<View
android:layout_width="5dp"
android:layout_height="fill_parent"
android:background="#color/red"
android:gravity="center" >
</View>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Coupons"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<View
android:layout_width="5dp"
android:layout_height="fill_parent"
android:background="#color/red"
android:gravity="center" >
</View>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Markets"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
</LinearLayout>
I'm not sure if this was just a mistake when you included your XML here, but you're missing a ">" after the parent LinearLayout.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/background_color"
android:orientation="vertical"
Should be
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/background_color"
android:orientation="vertical" >
Additionally, you are using weights in some of this parent layout's children, but you have not specified a weightSum total in the parent LinearLayout. Remember that a weightSum is the total weight to be distributed amongst the children, so their weights should add up to this weightSum. Also, just a head's up, but using nested weights (which you would be doing if you added that in) is bad for performance.
Maybe the best solution to your problem would be to explore a different layout option instead of using a LinearLayout? You could get it to work this way, though. Make the parent weightSum 7 and make sure you distribute this as desired to the children.
As per your picture (and using linear layouts), it should look something like this, I think:
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="7" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weight="4" >
// This one's child here - it has weight 1.
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="2"
android:weight="2" >
// This one's children here - they both have weight 1.
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="3"
android:weight="1" >
// This one's children here - they all have weight 1.
Don't forget to close the LinearLayouts as well. I haven't tested that code, either, so you will want to review it for possible errors.
I'm not sure if this is your only problem but when using weight your layout_width should be "0dp" for a horizontal orientation and layout_height should be "0dp" for a vertical orientation. So for example your first child should be
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:gravity="center_horizontal|center_vertical"
android:orientation="horizontal" >
because it belongs to a parent LinearLayout who's orientation is vertical
Update
Something like this should get you really close. Note I had to take out your resources to make it work in my editor so you will just have to put those back in
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:gravity="center_horizontal|center_vertical"
android:orientation="horizontal" >
<TextView
android:id="#+id/textDishes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:text="Dishes"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imageDishes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="1dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:measureWithLargestChild="true"
android:orientation="horizontal"
android:weightSum="2" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="#+id/textfood"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Food"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imagefood"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="fill_parent" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="#+id/textMalls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Malls"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imageMalls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="1dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:weightSum="3"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="App name"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="1dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Coupons"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="1dp" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Markets"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</LinearLayout>
</LinearLayout>
I have this xml layout code:
<?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"
android:gravity="center_horizontal"
android:background="#FFFFFF">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/nektaText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="10pt"
android:textAlignment="center"
android:text="example text will not be used" />
<ImageView
android:id="#+id/horilinee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:src="#drawable/horiline" />
<TableRow
android:id="#+id/table"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="bottom" >
<Button
android:id="#+id/send"
android:text="أرسل"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
<EditText
android:id="#+id/commenttext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="اكتب التعليق هنا"
android:minLines="1"
android:paddingRight="5dp"
android:paddingLeft="5dp"
android:scrollHorizontally="true"
android:scrollbars="vertical"
android:layout_weight="1"
android:singleLine="false" />
</TableRow>
<ImageView
android:id="#+id/horilineee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:src="#drawable/horiline" />
<ListView
android:id="#id/android:list"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:drawSelectorOnTop="false"
android:paddingLeft="5dp"
android:paddingRight="5dp" />
</TableLayout>
</ScrollView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center_horizontal" >
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="#+id/tableRow0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="bottom"
android:paddingBottom="10dp"
android:paddingTop="10dp" >
<ImageView
android:id="#+id/horiline"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/horiline" />
</TableRow>
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="bottom" >
<ImageView
android:id="#+id/share"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/share" />
<ImageView
android:id="#+id/block"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/block" />
<ImageView
android:id="#+id/thumbdown"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/thumbdown" />
<ImageView
android:id="#+id/thumbup"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/thumbup" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="bottom" >
<TextView
android:id="#+id/sharetext"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="شارك"
android:textSize="12dp" />
<TextView
android:id="#+id/blocktext"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="إبلاغ إساءة"
android:textSize="12dp" />
<TextView
android:id="#+id/dislikenumber"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:textColor="#FF0000"
android:textSize="12dp" />
<TextView
android:id="#+id/likenumber"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:textColor="#00FF00"
android:textSize="12dp" />
</TableRow>
</TableLayout>
</LinearLayout>
</RelativeLayout>
but it doesn't seems to be working as I want it to be. I need it like the following figure:
The problem with my code is the list view I can't stretch it to the bottom before the tablelayout. The other problem comes if the textview at the top is too long, it appears under the tablelayout and it's visible.
Also the tablelayout at the bottom shifted up when the keyboard is visible, I don't want this to happen.
Any suggestion please?
Have a single ListView in your layout. You can add other views(as shown in your diagram) as headers to the list view using addHeaderView() method. This way you will get the Scrolling effect as you desired.
Thank you all for your support. I came up with a better solution:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="70dp"
android:layout_weight="1" >
<TextView
android:id="#+id/nektaText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="example text will not be used"
android:textAlignment="center"
android:textSize="10pt" />
</ScrollView>
<ImageView
android:id="#+id/horilinee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:src="#drawable/horiline" />
<TableRow
android:id="#+id/table"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.5"
android:gravity="bottom" >
<Button
android:id="#+id/send"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="4"
android:text="أرسل" />
<EditText
android:id="#+id/commenttext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="اكتب التعليق هنا"
android:minLines="1"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:scrollHorizontally="true"
android:scrollbars="vertical"
android:singleLine="false" />
</TableRow>
<ImageView
android:id="#+id/horilineee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:src="#drawable/horiline" />
<ListView
android:id="#id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:drawSelectorOnTop="false"
android:paddingLeft="5dp"
android:paddingRight="5dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/layout0"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="end" >
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="#+id/tableRow0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="bottom"
android:paddingBottom="10dp"
android:paddingTop="10dp" >
<ImageView
android:id="#+id/horiline"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/horiline" />
</TableRow>
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="bottom" >
<ImageView
android:id="#+id/share"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/share" />
<ImageView
android:id="#+id/block"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/block" />
<ImageView
android:id="#+id/thumbdown"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/thumbdown" />
<ImageView
android:id="#+id/thumbup"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="#drawable/thumbup" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="bottom" >
<TextView
android:id="#+id/sharetext"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="شارك"
android:textSize="12dp" />
<TextView
android:id="#+id/blocktext"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="إبلاغ إساءة"
android:textSize="12dp" />
<TextView
android:id="#+id/dislikenumber"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:textColor="#FF0000"
android:textSize="12dp" />
<TextView
android:id="#+id/likenumber"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal"
android:textColor="#00FF00"
android:textSize="12dp" />
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
ScrollView needs to declare :
android:layout_above="#+id/Layout1"
Layout1 is the layout that host tableLayout1
But you will have some issues with ListView into scrollView
As there are only two Layout in your RelativeLayout, use LinearLayout. This will solve the overlap problem. Set the weight of ScrollView to keep the TableLayout at bottom.
The keyboard shift the Bottom table layout because it's mode is set to Resize. You will usually control this behavior through the android:windowSoftInputMode attribute on each definition in your AndroidManifest.xml. Set the value of this to adjustPan.