There is the following code:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.9"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="#+id/activityEvaluationYesterdayValueDisplay"
android:layout_width="15dip"
android:layout_height="wrap_content"
android:text="0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<com.ulnda.mypsych.views.VerticalSeekBar
android:id="#+id/activityEvaluationYesterdayValue"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:max="10"
android:progress="0" />
</LinearLayout>
Now I need to change LinearLayout to RelativeLayout. If I do it then RelativeLayout fill the whole screen, and it's bad. I understand that RelativeLayout doesn't use layout_weight for its work. Please, tell me, how can I fix it? I've tried to make LinearLayout wrapper for RelativeLayout, but it doesn't help.
UPDATE:
<?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" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.6"
android:orientation="vertical" >
<RelativeLayout
android:background="#000000"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
</LinearLayout>
</LinearLayout>
UPDATE 2: FUll code
<?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" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.5" >
<LinearLayout
android:weightSum="1.0"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.33"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.9">
<TextView
android:id="#+id/activityEvaluationYesterdayValueDisplay"
android:layout_width="15dip"
android:layout_height="wrap_content"
android:text="0"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/activityEvaluationYesterdayValue"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<com.ulnda.mypsych.views.VerticalSeekBar
android:id="#+id/activityEvaluationYesterdayValue"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:max="10"
android:progress="0" />
</RelativeLayout>
<TextView
android:id="#+id/TextView05"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.1"
android:gravity="center"
android:text="Yesterday"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.33"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.9"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="#+id/activityEvaluationTodayValueDisplay"
android:layout_width="20dip"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<com.ulnda.mypsych.views.VerticalSeekBar
android:id="#+id/activityEvaluationTodayValue"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:max="10"
android:progress="0" />
</LinearLayout>
<TextView
android:id="#+id/TextView03"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.1"
android:gravity="center"
android:text="Today"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.33"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.9"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="#+id/activityEvaluationTomorrowValueDisplay"
android:layout_width="20dip"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<com.ulnda.mypsych.views.VerticalSeekBar
android:id="#+id/activityEvaluationTomorrowValue"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:max="10"
android:progress="0" />
</LinearLayout>
<TextView
android:id="#+id/TextView02"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.1"
android:gravity="center"
android:text="Tomorrow"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
</LinearLayout>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="0dip"
android:layout_weight="0.5" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.33"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.9"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="#+id/activityEvaluationEnergyValueDisplay"
android:layout_width="20dip"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<com.ulnda.mypsych.views.VerticalSeekBar
android:id="#+id/activityEvaluationEnergyValue"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:max="10"
android:progress="0" />
</LinearLayout>
<TextView
android:id="#+id/TextView11"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.1"
android:gravity="center"
android:text="Energy"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.33"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.9"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="#+id/activityEvaluationWeatherValueDisplay"
android:layout_width="20dip"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<com.ulnda.mypsych.views.VerticalSeekBar
android:id="#+id/activityEvaluationWeatherValue"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:max="10"
android:progress="0" />
</LinearLayout>
<TextView
android:id="#+id/TextView09"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.1"
android:gravity="center"
android:text="Weather"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="0.33"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.9"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="#+id/activityEvaluationHoursSleptValueDisplay"
android:layout_width="20dip"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="0"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
<com.ulnda.mypsych.views.VerticalSeekBar
android:id="#+id/activityEvaluationHoursSleptValue"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:max="10"
android:progress="0" />
</LinearLayout>
<TextView
android:id="#+id/TextView07"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.1"
android:gravity="center"
android:text="Hours Slept"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold" />
</LinearLayout>
</TableRow>
</TableLayout>
</LinearLayout>
Why RelativeLayout fill whole screen, not 0.6 ?
android:layout_weight makes sense only for LinearLayout. Lint should aware you about with a warning
RelativeLayout is the only one child who has layout_weight attribute so you should also specify weightSum:
<?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:weightSum="1">
<RelativeLayout
android:background="#ff0000"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.6">
</RelativeLayout>
</LinearLayout>
Related
LinearLayout with editText on the bottom overlays the content of scrollView, which is filled programmatically.
How to avoid this please?
I have simplified the XML in vain in my first version of this message.
I have added the full code now
I'd like to keep my editText height expandable.
<?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:background="#color/backNormal"
android:orientation="vertical"
>
<include layout="#layout/adview"
android:layout_alignParentTop="true"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:orientation="horizontal"
android:background="#color/back1"
android:layout_below="#+id/adView"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
>
<TextView
android:id="#+id/textChatSubjectTitle"
android:text='Subject'
android:gravity="left|center_vertical"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_weight="5"
android:layout_height="wrap_content"
android:textColor="#color/text1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="normal"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left|center_vertical"
android:orientation="horizontal"
>
<TextView
android:id="#+id/textChatActn"
android:text='0'
android:gravity="left|center_vertical"
android:layout_marginLeft="10dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/textWhite"
android:background="#color/gray"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
<TextView
android:id="#+id/textChatUsers"
android:text='users'
android:gravity="left|center_vertical"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/darkGray"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="normal"
/>
</LinearLayout>
</LinearLayout>
<ImageView
android:id="#+id/imageChatImageTitle"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="right"
/>
</LinearLayout>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scrollChat"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/backNormal"
android:orientation="vertical"
android:layout_below="#+id/top"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearChat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
</LinearLayout>
</ScrollView>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/back1"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
>
<ImageView
android:id="#+id/buttonClip"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:src="#drawable/clip32"
android:layout_weight="1"
android:layout_gravity= "center_vertical|center_horizontal"
/>
<EditText
android:id="#+id/editChatMessage"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="textMultiLine|textCapSentences"
android:minLines="1"
android:gravity="top|left"
android:maxLines="5"
android:maxLength="500"
android:layout_marginRight="5dp"
android:text=''
android:layout_gravity= "center_vertical|center_horizontal"
android:textColor="#color/text1"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_weight="5"
android:background="#drawable/edit"
android:scrollHorizontally="false"
android:cursorVisible="true"
android:textCursorDrawable="#null"
/>
<Button
android:id="#+id/buttonChatSend"
android:text='>'
android:layout_marginRight="5dp"
android:gravity="center"
android:layout_gravity= "center_vertical|center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/darkGray"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:background="#drawable/button_normal"
/>
</LinearLayout>
</RelativeLayout>
Any ideas please?
Thanks!
I suggest using Relative layout for parent. And then add the rule above.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ScrollView
android:id="#+id/scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#+id/llButton"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linear"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/llButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<EditText
android:id="#+id/editMessage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="top|left"
android:inputType="textMultiLine|textCapSentences"
android:maxLines="5"
android:minLines="3"
android:scrollHorizontally="false" />
<Button
android:id="#+id/buttonSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center"
android:text='send'
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
Please try the below code, if it solves your problem.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/linear1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/linear"
android:layout_width="match_parent"
android:layout_height="1200dp"
android:background="#ff0000"
android:orientation="vertical"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="#+id/editMessage"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:background="#drawable/edit"
android:gravity="top|left"
android:inputType="textMultiLine|textCapSentences"
android:maxLines="5"
android:minLines="3"
android:textColor="#color/text1"
android:scrollHorizontally="false"
/>
<Button
android:id="#+id/buttonSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:background="#drawable/button_normal"
android:gravity="center"
android:text="send"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</LinearLayout>
</ScrollView>
I have created a custom notification XML file. I would like to draw a vertical line like the horizontal line in the below picture. I have been trying various ways couldn't achieve it. The orientation in xml from horizontal to vertical didn't help me.
Check my screenshot below:I would like to get the vertical line instead of the red line.
Tried the following code:
<LinearLayout
android:id="#+id/horizontalLayout"
android:layout_width="match_parent"
android:layout_height="2dip"
android:background="#000000"
android:orientation="vertical" >
</LinearLayout>
Below is my XML:
<?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="#151515"
android:baselineAligned="false"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/iconimagelayout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:paddingLeft="5dp" >
<ImageView
android:id="#+id/iconimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/icon"
android:src="#drawable/cancel" />
</LinearLayout>
<LinearLayout
android:id="#+id/NameLayout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".70"
android:orientation="vertical"
android:paddingLeft="10sp" >
<LinearLayout
android:id="#+id/topTextlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#2E2E2E"
android:gravity="center_horizontal"
android:paddingBottom="5dp" >
<TextView
android:id="#+id/topText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:text="TITLE"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/horizontalLayout"
android:layout_width="match_parent"
android:layout_height="2dip"
android:background="#000000"
android:orientation="horizontal" >
</LinearLayout>
<LinearLayout
android:id="#+id/textLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#1C1C1C"
android:paddingTop="5dp" >
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingLeft="5dp"
android:text="MESSAGE BODY"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/horizontalLayout2"
android:layout_width="match_parent"
android:layout_height="2dip"
android:background="#000000"
android:orientation="horizontal" >
</LinearLayout>
<LinearLayout
android:id="#+id/alldismisslayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#2E2E2E" >
<ImageView
android:id="#+id/dismissicon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/dismissicon"
android:src="#drawable/cancel" />
<LinearLayout
android:id="#+id/dismissLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|left" >
<TextView
android:id="#+id/dismissText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text="#string/notificationdismiss"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Not sure where exactly I have to put the vertical line code.
You can use following to create the vertical line.
<View
android:layout_width="4dip"
android:layout_height="match_parent"
android:background="#FF000000"/>
Put this code after your first cancel imageview.So that your final code becomes
<LinearLayout
android:id="#+id/iconimagelayout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:paddingLeft="5dp" >
<ImageView
android:id="#+id/iconimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/icon"
android:src="#drawable/cancel" />
</LinearLayout>
<View
android:layout_width="4dip"
android:layout_height="match_parent"
android:background="#FF000000"/>
<LinearLayout
android:id="#+id/NameLayout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".70"
android:orientation="vertical"
android:paddingLeft="10sp" >
<LinearLayout
android:id="#+id/topTextlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#2E2E2E"
android:gravity="center_horizontal"
android:paddingBottom="5dp" >
<TextView
android:id="#+id/topText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:text="TITLE"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/horizontalLayout"
android:layout_width="match_parent"
android:layout_height="2dip"
android:background="#000000"
android:orientation="horizontal" >
</LinearLayout>
<LinearLayout
android:id="#+id/textLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#1C1C1C"
android:paddingTop="5dp" >
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingLeft="5dp"
android:text="MESSAGE BODY"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/horizontalLayout2"
android:layout_width="match_parent"
android:layout_height="2dip"
android:background="#000000"
android:orientation="horizontal" >
</LinearLayout>
<LinearLayout
android:id="#+id/alldismisslayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#2E2E2E" >
<ImageView
android:id="#+id/dismissicon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/dismissicon"
android:src="#drawable/cancel" />
<LinearLayout
android:id="#+id/dismissLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|left" >
<TextView
android:id="#+id/dismissText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text="#string/notificationdismiss"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Hope it helps.
Just use proper backgrounds and margin if you need
Here is the screenshot
XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#151515"
android:baselineAligned="false"
>
<ImageView
android:id="#+id/iconimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/topText"
android:contentDescription="string/icon"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/topText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#2E2E2E"
android:layout_centerHorizontal="true"
android:text="TITLE"
android:textColor="#FFFFFF"
android:textSize="18sp" />
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:layout_below="#+id/topText"
android:layout_toRightOf="#+id/iconimage"
android:layout_margin="10dp"
android:background="#1C1C1C"
android:text="MESSAGE BODY"
android:textColor="#FFFFFF"
android:textSize="18sp" />
<ImageView
android:id="#+id/dismissicon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/text"
android:layout_toRightOf="#+id/iconimage"
android:contentDescription="string/dismissicon"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/dismissText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_toRightOf="#+id/dismissicon"
android:layout_below="#+id/text"
android:background="#2E2E2E"
android:text="notificationdismiss"
android:textColor="#FFFFFF"
android:textSize="18sp" />
<TextView android:layout_width="2dp"
android:layout_height="wrap_content"
android:background="#ff0000"
android:layout_alignRight="#+id/iconimage"
android:layout_alignBottom="#+id/dismissicon"
android:layout_alignTop="#+id/topText"
/>
</RelativeLayout>
hey try this with less layout hierarchy
<?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="wrap_content"
android:background="#1C1C1C"
android:baselineAligned="false"
android:orientation="horizontal" >
<ImageView
android:id="#+id/iconimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#drawable/cancel" />
<View
android:layout_width="3dp"
android:layout_height="fill_parent"
android:layout_marginLeft="3dp"
android:background="#color/GREEN" />
<LinearLayout
android:id="#+id/NameLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/topTextlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#2E2E2E"
android:gravity="center_horizontal"
android:paddingBottom="5dp" >
<TextView
android:id="#+id/topText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="5dp"
android:text="TITLE"
android:textColor="#color/WHITE"
android:textSize="18sp" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="3dp"
android:background="#color/your_color" />
<LinearLayout
android:id="#+id/textLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#1C1C1C"
android:paddingTop="5dp" >
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingLeft="5dp"
android:text="MESSAGE BODY"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="3dp"
android:background="#color/GREEN" />
<LinearLayout
android:id="#+id/alldismisslayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#2E2E2E" >
<TextView
android:id="#+id/dismissText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/cancel"
android:drawablePadding="5dp"
android:paddingLeft="5dp"
android:text="#string/notificationdismiss"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
Try this way,hope this will help you to solve your problem.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#151515"
android:baselineAligned="false"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/iconimagelayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:paddingLeft="5dp" >
<ImageView
android:id="#+id/iconimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/icon"
android:src="#drawable/ic_launcher" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#FF0000"/>
<LinearLayout
android:id="#+id/NameLayout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:paddingLeft="10dp">
<LinearLayout
android:id="#+id/topTextlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#2E2E2E"
android:gravity="center_horizontal"
android:padding="10dp">
<TextView
android:id="#+id/topText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TITLE"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/horizontalLayout"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#000000"
android:orientation="horizontal" >
</LinearLayout>
<LinearLayout
android:id="#+id/textLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#1C1C1C"
android:padding="10dp">
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MESSAGE BODY"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/horizontalLayout2"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#000000"
android:orientation="horizontal" >
</LinearLayout>
<LinearLayout
android:id="#+id/alldismisslayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#2E2E2E"
android:gravity="center">
<ImageView
android:id="#+id/dismissicon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/dismissicon"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:id="#+id/dismissLayout"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center"
android:paddingLeft="5dp">
<TextView
android:id="#+id/dismissText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/notificationdismiss"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Try This:
Create one colored vertical line 9 patch image
then use that image in View in android xml file
Change your XML file like:
<?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="#151515"
android:baselineAligned="false"
android:orientation="horizontal" >
<LinearLayout
android:id="#+id/iconimagelayout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal"
android:layout_marginRight="10dp"
android:paddingLeft="5dp" >
<ImageView
android:id="#+id/iconimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="icon"
android:src="#drawable/ic_launcher" />
<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="#drawable/untitled" />
</LinearLayout>
<LinearLayout
android:id="#+id/NameLayout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".70"
android:orientation="vertical"
android:paddingLeft="10sp" >
<LinearLayout
android:id="#+id/topTextlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#2E2E2E"
android:gravity="center_horizontal"
android:paddingBottom="5dp" >
<TextView
android:id="#+id/topText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:text="TITLE"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/horizontalLayout"
android:layout_width="match_parent"
android:layout_height="2dip"
android:background="#000000"
android:orientation="horizontal" >
</LinearLayout>
<LinearLayout
android:id="#+id/textLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#1C1C1C"
android:paddingTop="5dp" >
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingLeft="5dp"
android:text="MESSAGE BODY"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/horizontalLayout2"
android:layout_width="match_parent"
android:layout_height="2dip"
android:background="#000000"
android:orientation="horizontal" >
</LinearLayout>
<LinearLayout
android:id="#+id/alldismisslayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#2E2E2E" >
<ImageView
android:id="#+id/dismissicon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="dismissicon"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:id="#+id/dismissLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|left" >
<TextView
android:id="#+id/dismissText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text="notificationdismiss"
android:textColor="#FFFFFF"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Here in:
<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="#drawable/untitled" />
untitled is my 9 patch image.
9 patch image because it could be stretched as per the screen resolution
I have a complex layout in XML.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/mainbackground"
android:orientation="vertical"
android:weightSum="1" >
<LinearLayout
android:id="#+id/selector"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="0.1"
android:orientation="horizontal"
android:weightSum="1" >
<TextView
style="#style/T2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:gravity="center"
android:text="#string/month" />
<TextView
android:id="#+id/byday"
style="#style/T2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:background="#color/tertiarybackground"
android:gravity="center"
android:text="#string/day"
android:textColor="#color/links" />
</LinearLayout>
<RelativeLayout
android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_below="#+id/selector"
android:layout_weight="0.1"
android:background="#color/mainbackground" >
<RelativeLayout
android:id="#+id/previous"
android:layout_width="48dip"
android:layout_height="48dip"
android:layout_alignParentLeft="true" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/arrow_left" />
</RelativeLayout>
<TextView
android:id="#+id/title"
style="#style/H2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dip"
android:textColor="#000000" />
<RelativeLayout
android:id="#+id/next"
android:layout_width="48dip"
android:layout_height="48dip"
android:layout_alignParentRight="true" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#drawable/arrow_right" />
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/daysoftheweek"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="#+id/header"
android:layout_weight="0.05"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" >
<TextView
style="#style/T2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/sun" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" >
<TextView
style="#style/T2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/mon" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" >
<TextView
style="#style/T2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tue" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" >
<TextView
style="#style/T2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/wed" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" >
<TextView
style="#style/T2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/thu" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" >
<TextView
style="#style/T2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/fri" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" >
<TextView
style="#style/T2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/sat" />
</LinearLayout>
</LinearLayout>
<GridView
android:id="#+id/gridview"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_below="#+id/daysoftheweek"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:listSelector="#android:color/transparent"
android:numColumns="7"
android:stretchMode="columnWidth" />
<ScrollView
android:id="#+id/scroll"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.25"
android:fadeScrollbars="false"
android:gravity="top"
android:scrollbarAlwaysDrawHorizontalTrack="true"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarFadeDuration="0" >
<LinearLayout
android:id="#+id/text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_gravity="top"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
</LinearLayout>
Now programatically I add rows to the LinearLayout text:
rLayout = (LinearLayout) findViewById(R.id.text);
View row = li.inflate(R.layout.event_row, null);
rLayout.addView(row);
This is the result I get.
As you can see the row are placed in the center, not at the top of the text LinearLayout
Thanks for your help!
Use layout_gravity="top" attribute for the LinearLayout.
<LinearLayout
android:id="#+id/text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_gravity="top"
android:orientation="vertical" >
</LinearLayout>
SOLVED!
The problem was in the GridView above:
I changed form:
<GridView
android:id="#+id/gridview"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_below="#+id/daysoftheweek"
android:layout_gravity="center_horizontal"
android:layout_weight="0.5"
android:listSelector="#android:color/transparent"
android:numColumns="7"
android:stretchMode="columnWidth" />
to
<GridView
android:id="#+id/gridview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/daysoftheweek"
android:layout_gravity="center_horizontal"
android:listSelector="#android:color/transparent"
android:numColumns="7"
android:stretchMode="columnWidth" />
I want to make this layout on my main screen of my application.
I have stripes for each image block shown above.
Please guide my which layout (RelativeLayout, LinearLayout...etc) should I use to achieve this.
I am new to android development. I have experimented few layout but not having success. I also used FrameLayout
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">
<TableRow>
<FrameLayout
android:id="#+id/inboxLargeButton"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/inbox_normal"
android:id="#+id/buttonWeddingDayCheatSheet"
android:layout_gravity="center_horizontal">
</ImageView>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="2631"
android:layout_gravity="bottom"
android:gravity="center"
android:textColor="#fff"
android:textSize="50dp" />
</FrameLayout>
<FrameLayout
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/outbox_normal"
android:id="#+id/buttonShareFavoriteRecipe"
android:layout_gravity="center_horizontal">
</ImageView>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="0296"
android:layout_gravity="bottom"
android:gravity="center"
android:textColor="#fff"
android:textSize="50dp" />
</FrameLayout>
</TableRow>
<TableRow>
<FrameLayout
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/header_left_normal"
android:id="#+id/buttonWeddingDayCheatSheet"
android:layout_gravity="center_horizontal">
</ImageView>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Most sent"
android:layout_gravity="bottom"
android:gravity="center"
android:textColor="#fff"
android:textSize="15dp" />
</FrameLayout>
<FrameLayout
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/header_right_normal"
android:id="#+id/buttonShareFavoriteRecipe"
android:layout_gravity="center_horizontal">
</ImageView>
</FrameLayout>
</TableRow>
<TableRow>
<FrameLayout
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/body_left_normal"
android:id="#+id/buttonWeddingDayCheatSheet"
android:layout_gravity="center_horizontal">
</ImageView>
</FrameLayout>
<FrameLayout
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/body_right_normal"
android:id="#+id/buttonShareFavoriteRecipe"
android:layout_gravity="center_horizontal">
</ImageView>
</FrameLayout>
</TableRow>
</TableLayout>
As I want to make the each block clickable too.
Try this code:
<?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:stretchColumns="1" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="#+id/inboxLargeButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:id="#+id/buttonWeddingDayCheatSheet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/ic_launcher" >
</ImageView>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="center"
android:text="2631"
android:textColor="#fff"
android:textSize="50dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:id="#+id/buttonShareFavoriteRecipe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/ic_launcher" >
</ImageView>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="center"
android:text="0296"
android:textColor="#fff"
android:textSize="50dp" />
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:id="#+id/buttonWeddingDayCheatSheet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/ic_launcher" >
</ImageView>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="center"
android:text="Most sent"
android:textColor="#fff"
android:textSize="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:id="#+id/buttonShareFavoriteRecipe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/ic_launcher" >
</ImageView>
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:id="#+id/buttonWeddingDayCheatSheet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/ic_launcher" >
</ImageView>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<ImageView
android:id="#+id/buttonShareFavoriteRecipe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/ic_launcher" >
</ImageView>
</LinearLayout>
</TableRow>
</TableLayout>
I want to design following design in android using Linear layout
I had written following code but not working
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_weight="1"
android:layout_height="fill_parent" android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_weight="1" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/alert_dark_frame" />
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="2" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentLeft="true"
android:text="TextView" android:layout_weight="1" />
<TextView
android:id="#+id/textView2" android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentRight="true"
android:text="TextView" />
</LinearLayout>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" android:hint="TestData"/>
</LinearLayout>
</LinearLayout>
it gives me output like
can anyone pointout me.. where is problem???
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/alert_dark_frame" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="dfasdfasdfasfasf" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="07 DEc" />
</LinearLayout>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dskfhasjkldfhadjklsfhadjklsfhajkldfhadjklsfhajklsfhajklsdfhajklsdfhajklsdfhajkldf" />
</LinearLayout>
</LinearLayout>
This will work... :)
This will work for you.
<?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:padding="5dip" >
<ImageView
android:id="#+id/icon"
android:layout_width="70px"
android:layout_height="50px"
android:layout_marginRight="3dip"
android:src="#drawable/ic_launcher" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/toptext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="dsggsdggfsgf"
android:textColor="#000000"
android:textSize="16px"
android:textStyle="bold" />
<TextView
android:id="#+id/datetext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:maxLines="1"
android:text="1 dec 2012"
android:textColor="#cccccc"
android:textSize="12px"
android:textStyle="bold" />
</RelativeLayout>
<TextView
android:id="#+id/bottomtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dsggsdggfsgfwaffgdgafgggfdgfdgsfgfdgdfsgdfdsggsdggfsgfwaffgdgafgggfdgfdgsfgfdgdfsgdfdsggsdggfsgfwaffgdgafgggfdgfdgsfgfdgdfsgdfdsggsdggfsgfwaffgdgafgggfdgfdgsfgfdgdfsgdf"
android:textColor="#696969"
android:textSize="12px" />
</LinearLayout>
</LinearLayout>
I think you can use relativelayout at first level, like the following:
<relativelayout>
<imageview align to parent top, left, bottom>
<linearlayout align to parent to, right, right to image view>
<textview1/>
<textview2/>
</linearlayout>
<textview align to parent bottom, right, righto to image view, below linearlayout>
</relativelayout>
This should work. But it will be better if you use RelativeLayout
<?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="wrap_content"
android:layout_weight="1"
android:background="#android:color/white"
android:orientation="horizontal" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#android:drawable/alert_dark_frame" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="2" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
</LinearLayout>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="TestData"
android:text="TextView" />
</LinearLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_weight="1"
android:layout_height="fill_parent" android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:weightSum="3"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#android:drawable/alert_dark_frame"
android:layout_weight="2"/>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3"
android:orientation="horizontal" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="hfdfhfj" android:layout_weight="2" />
<TextView
android:id="#+id/textView2" android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6 Dec 2012" />
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="fkjfkdsnfdsnfkdsn\nmnfkfknfkdf\nfknf" android:hint="TestData"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Try this code.it is exactly what you want.