I created a custom list view with table layout.
Now I want to show the text on the right. (You can see an example in the image, I cannot put this in the post)
But I cannot move textviews to the right.
http://i.stack.imgur.com/x57ly.png
my code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top"
android:background="#drawable/bar_bg"
android:paddingTop="0dip" >
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
tools:ignore="RtlHardcoded" >
<TableRow
android:layout_marginTop="3dp"
tools:ignore="UselessParent"
>
<LinearLayout
android:layout_width="120dp"
android:layout_height="82dp"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingTop="5dp"
tools:ignore="RtlSymmetry" >
<ImageView
android:id="#+id/image"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_gravity="left|top"
android:scaleType="centerCrop"
tools:ignore="ContentDescription" />
</LinearLayout>
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:paddingTop="0dp" >
<TableRow
android:layout_width="fill_parent"
android:layout_gravity="center_vertical"
android:textDirection="rtl"
tools:ignore="UnusedAttribute" >
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:layout_marginLeft="5dp"
android:layout_marginTop="9dp"
android:layout_marginBottom="10dp"
android:paddingRight="6dp"
android:gravity="right"
android:layout_span="1"
android:layout_weight="1"
android:textColor="#000000"
android:textSize="16sp" />
</TableRow>
<TableRow android:layout_width="fill_parent" >
<TextView
android:id="#+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:gravity="right"
android:paddingRight="6dp"
android:textColor="#000000"
android:textSize="16sp"
tools:ignore="RtlHardcoded" />
</TableRow>
</TableLayout>
</TableRow>
</TableLayout>
<TextView
android:id="#+id/tvdarsad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="16dp"
android:textSize="22sp"
android:textAlignment="center"
android:textStyle="bold"
android:layout_marginTop="18dp"
android:background="#drawable/badge_ifaux"
android:text="%20"
android:textColor="#FFFFFF" />
<ImageView
android:id="#+id/imagecolor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="15dp"
android:layout_marginRight="4dp"
android:layout_alignParentTop="true"
android:src="#drawable/color1"/>
</RelativeLayout>
I think you implemented a complicated solution. You can achieve the same result using LinearLayout and distributing the weight between its views.
Here I post you have an example with your code with the same result of the photo.
Hope it helps.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3">
<ImageView
android:id="#+id/image"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".5"
tools:ignore="ContentDescription" />
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="2"
android:layout_marginLeft="20dp"
android:orientation="vertical">
<TextView
android:id="#+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="text1"
android:textColor="#000000"
android:textSize="16sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="text2"
android:textColor="#000000"
android:textSize="16sp" />
</LinearLayout>
<TextView
android:id="#+id/text2"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".3"
android:textColor="#000000"
android:textSize="16sp" />
<ImageView
android:id="#+id/imagecolor"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".2"
android:src="#drawable/abc_btn_borderless_material"/>
</LinearLayout>
Related
I am trying to add a table inside a linear layout. Inside my linear layout there is textview, spinner. When I try to add a table layout it doesn't align correctly. Below is my code
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/cardLayout"
android:orientation="vertical">
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Product"
android:gravity="center"
android:textStyle="bold"
android:textSize="18sp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10sp"
android:layout_margin="10sp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".5"
android:orientation="vertical">
<Spinner
android:id="#+id/product_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
</LinearLayout>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
>
<TableRow android:background="#0079D6" android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Product Name" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Sale" />
</TableRow>
<TableRow android:background="#DAE8FC" android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="" />
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
Output
Expected Output
I must be missing something that I don't know. How can I align them equally just like in the above image
Any help would be highly appreciated.
Try using below code:
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Product"
android:gravity="center"
android:textStyle="bold"
android:textSize="18sp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center">
<Spinner
android:id="#+id/product_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
/>
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_gravity="center"
>
<TableRow android:background="#0079D6" android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Product Name" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Sale" />
</TableRow>
<TableRow android:background="#DAE8FC" android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="" />
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
i am new in android studio.
currently i making listview, i want to make layout like this picture :
this is my code now
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="3">
<TableLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginLeft="10dp"
>
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Type"
android:textSize="18dp"
android:fontFamily="sans-serif"
android:textColor="#color/black"
android:id="#+id/tvTipeRequest"
android:width="130dp" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
>
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Date"
android:fontFamily="sans-serif"
android:id="#+id/tvTanggalRequest"
android:textSize="15dp"
android:width="130dp" />
</TableRow>
</TableLayout>
<TextView
android:layout_width="1dp"
android:layout_weight="1"
android:layout_height="50dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/black"
android:text="Status"
android:textSize="15dp"
android:gravity="end"
android:paddingTop="10dp"
android:fontFamily="sans-serif"
android:layout_marginTop="15dp"
android:id="#+id/tvStatus"
android:layout_column="38" />
</TableRow>
</TableLayout>
i realize that tablerow cant do the rowspan, so it didnt work out.
is there any simple way to do that?
Use this hierarchy:
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:weightSum="1"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="0.2"
android:orientation="vertical"
android:layout_height="wrap_content">
<!--ImageView here-->
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="0.8"
android:orientation="vertical"
android:layout_height="wrap_content">
<!--All textViews here-->
</LinearLayout>
</LinearLayout>
You can have a single relative layout as your view container. That would be more efficient.
Read.
Layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/image_view"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:src="#drawable/circle" />
<TextView
android:id="#+id/text_view_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/image_view"
android:text="text_1"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/text_view_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/text_view_1"
android:layout_toRightOf="#+id/image_view"
android:text="text_2"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/text_view_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/text_view_2"
android:layout_toRightOf="#+id/image_view"
android:text="text_3"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/text_view_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/text_view_3"
android:layout_toRightOf="#+id/image_view"
android:text="text_4"
android:textColor="#android:color/black" />
</RelativeLayout>
Output:
I would like show my Page view header like below,
I'm using the following layout using, but the image and second textview not moving to right, its all align center.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="6"
android:background="#drawable/transbg"
android:gravity="center"
android:orientation="vertical" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="6"
android:gravity="center"
>
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Magasin"
android:textColor="#FFF"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:src="#drawable/yellow2" />
<TextView
android:id="#+id/tvCredits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="test"
android:textColor="#fff"
android:textSize="16sp" />
</LinearLayout>
</TableRow>
</LinearLayout>
</LinearLayout>
how I can align one image view and textview right aligned.
Check out this one and let me know if it is what you want.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:background="#drawable/ic_launcher"
android:gravity="center"
android:orientation="vertical" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:background="#android:color/black"
android:gravity="center" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Magasin"
android:textColor="#FFF"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:src="#drawable/ic_launcher"
android:layout_toLeftOf="#+id/tvCredits" />
<TextView
android:id="#+id/tvCredits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="test"
android:textColor="#fff"
android:textSize="16sp" />
</RelativeLayout>
</TableRow>
</LinearLayout>
EDIT : If you want to make the same layout with easier and more efficient way, you can use this one.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/black" >
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Magasin"
android:textColor="#FFF"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/tvCredits"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/tvCredits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="test"
android:textColor="#fff"
android:textSize="16sp" />
</RelativeLayout>
// try this way
<?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:gravity="center"
android:padding="5dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/txtName"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Magasin"
android:textColor="#FFF"
android:gravity="center"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"
android:adjustViewBounds="true"/>
<TextView
android:id="#+id/tvCredits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test"
android:textColor="#fff"
android:textSize="16sp"
android:layout_marginLeft="5dp"/>
</LinearLayout>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="right">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="6"
android:background="#drawable/transbg"
android:gravity="center"
android:orientation="vertical" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="6"
android:gravity="center"
>
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Magasin"
android:textColor="#FFF"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="right|center"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:src="#drawable/yellow2" />
<TextView
android:id="#+id/tvCredits"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="test"
android:textColor="#fff"
android:textSize="16sp" />
</LinearLayout>
</TableRow>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Can anyone tell me why this (the circled part) is happening? This happened immediately after I added it to the activity.
The all important (and relevant) part of the xml:
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Delivery Approval" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical|center_horizontal|center"
android:layout_weight="1"
android:background="#color/CornflowerBlue"
android:padding="5dp"
android:text="Quantity Approved?"
android:textStyle="bold" />
<TextView
android:id="#+id/textView3"
style="#style/subText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Is the quantity being delivered correct and all accounted for?"
android:textStyle="italic" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<RadioGroup
android:id="#+id/radioGroup1"
style="#style/subRadioButtons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="10dp"
android:layout_weight="1" >
<RadioButton
android:id="#+id/quaYes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="false"
android:text="Yes" />
<RadioButton
android:id="#+id/quaNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="No" />
</RadioGroup>
</LinearLayout>
</LinearLayout>
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:padding="5dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/textView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/CornflowerBlue"
android:padding="5dp"
android:text="Condition Approved?"
android:textStyle="bold" />
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Is the condition of delivery satisfactory?"
android:textAlignment="center"
android:textAppearance="#style/subText"
android:textStyle="italic" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<RadioGroup
android:id="#+id/radioGroup2"
style="#style/subRadioButtons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="10dp"
android:layout_weight="1" >
<RadioButton
android:id="#+id/conYes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="false"
android:text="Yes" />
<RadioButton
android:id="#+id/conNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="No" />
</RadioGroup>
</LinearLayout>
</LinearLayout>
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/textView6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#color/CornflowerBlue"
android:padding="5dp"
android:text="Proof"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:id="#+id/textView7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="If delivery has not been approved. Please provide proof. Using either Photographic evidence, or voice, detailing issue."
android:textAppearance="#style/subText"
android:textStyle="italic" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="128dp"
android:layout_height="64dp"
android:layout_gravity="center_vertical|start"
android:layout_weight="1"
android:scaleType="fitCenter"
android:src="#drawable/icon_photo" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="128dp"
android:layout_height="64dp"
android:layout_gravity="center_vertical|end"
android:layout_weight="1"
android:scaleType="fitCenter"
android:src="#drawable/icon_record" />
</LinearLayout>
</LinearLayout>
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/tableLayout1"
android:orientation="vertical"
android:padding="5dp" >
<Button
android:id="#+id/cmdNext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Customer Signature"
android:textAlignment="center"
android:textSize="12sp" />
</LinearLayout>
</RelativeLayout>
As you can see I've set textAlignment to center, but it does nothing. Is this an issue with using a Table layout maybe? Possibly, due to other layouts in the activity, it's being forced over one side?
Edit #1 - Posted entire XML file, as it stands currently.
Edit #2 - Have tried running on the device, but still the same formatting issue, so it's definitely somewhere in my XML, maybe an inherited property (which I tend to avoid, for exactly this reason). I've also attempted to set the position of the text to any other position and nothing changes in the designer, nor on the device/emulator.
Many thanks!
Try this one (however, I couldn't test it so I am not sure)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/relativeLayout1">
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true">
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Delivery Approval"
android:gravity="left" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical|center_horizontal|center"
android:layout_weight="1"
android:background="#color/CornflowerBlue"
android:padding="5dp"
android:text="Quantity Approved?"
android:textStyle="bold" />
<TextView
android:id="#+id/textView3"
style="#style/subText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Is the quantity being delivered correct and all accounted for?"
android:textStyle="italic" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<RadioGroup
android:id="#+id/radioGroup1"
style="#style/subRadioButtons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="10dp"
android:layout_weight="1">
<RadioButton
android:id="#+id/quaYes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="false"
android:text="Yes" />
<RadioButton
android:id="#+id/quaNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="No" />
</RadioGroup>
</LinearLayout>
</LinearLayout>
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/textView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/CornflowerBlue"
android:padding="5dp"
android:text="Condition Approved?"
android:textStyle="bold" />
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Is the condition of delivery satisfactory?"
android:textAppearance="#style/subText"
android:textStyle="italic" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<RadioGroup
android:id="#+id/radioGroup2"
style="#style/subRadioButtons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="10dp"
android:layout_weight="1">
<RadioButton
android:id="#+id/conYes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="false"
android:text="Yes" />
<RadioButton
android:id="#+id/conNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="No" />
</RadioGroup>
</LinearLayout>
</LinearLayout>
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/textView6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#color/CornflowerBlue"
android:padding="5dp"
android:text="Proof"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/textView7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="If delivery has not been approved. Please provide proof. Using either Photographic evidence, or voice, detailing issue."
android:textAppearance="#style/subText"
android:textStyle="italic" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageView
android:id="#+id/imageView1"
android:layout_width="128dp"
android:layout_height="64dp"
android:layout_gravity="center_vertical|start"
android:layout_weight="1"
android:scaleType="fitCenter"
android:src="#drawable/icon_photo" />
<ImageView
android:id="#+id/imageView2"
android:layout_width="128dp"
android:layout_height="64dp"
android:layout_gravity="center_vertical|end"
android:layout_weight="1"
android:scaleType="fitCenter"
android:src="#drawable/icon_record" />
</LinearLayout>
</LinearLayout>
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/tableLayout1"
android:orientation="vertical"
android:padding="5dp"
android:gravity="center">
<Button
android:id="#+id/cmdNext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Customer Signature"
android:textSize="12sp" />
</LinearLayout>
</RelativeLayout>
I have a situation, in that situation one view contain imageviews on upper part and list view in the lower part and when we scrolling it is only scroll listview part but i have to scroll whole view simultaneously with single scroll.
I have used add header functionality of list view but in that i have to put seperate xml file of imageview and listview and i need to put them in one xml file. how can i do it..
<ViewFlipper
android:id="#+id/viewFlipper"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/header_relativelayout" >
<!-- //settings First view Setting -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="3dp"
android:paddingRight="3dp" >
<LinearLayout
android:id="#+id/first_view"
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:orientation="horizontal"
android:weightSum="3" >
<TextView
android:id="#+id/textView_chooseteam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="d"
android:textColor="#color/gray"
android:textSize="10sp"
android:visibility="invisible" />
<ImageView
android:id="#+id/imageView_cbk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="#drawable/cbk_btn" />
<TextView
android:id="#+id/textView_chooseteam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="d"
android:textColor="#color/gray"
android:textSize="20sp"
android:visibility="invisible" />
<ImageView
android:id="#+id/imageView_cfb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="#drawable/cfb_btn" />
<TextView
android:id="#+id/textView_chooseteam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="d"
android:textColor="#color/gray"
android:textSize="20sp"
android:visibility="invisible" />
<ImageView
android:id="#+id/imageView_mlb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="#drawable/mlb_btn" />
<TextView
android:id="#+id/textView_chooseteam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="d"
android:textColor="#color/gray"
android:textSize="10sp"
android:visibility="invisible" />
</LinearLayout>
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:text="#string/Games_Placebet_chooseteam"
android:textColor="#color/gray"
android:textSize="10sp"
android:textStyle="bold"
android:visibility="invisible" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="3" >
<TextView
android:id="#+id/textView_chooseteam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="d"
android:textColor="#color/gray"
android:textSize="10sp"
android:visibility="invisible" />
<ImageView
android:id="#+id/imageView_nba"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="#drawable/nba_btn" />
<TextView
android:id="#+id/textView_chooseteam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="d"
android:textColor="#color/gray"
android:textSize="20sp"
android:visibility="invisible" />
<ImageView
android:id="#+id/imageView_nfl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="#drawable/nfl_btn" />
<TextView
android:id="#+id/textView_chooseteam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="d"
android:textColor="#color/gray"
android:textSize="20sp"
android:visibility="invisible" />
<ImageView
android:id="#+id/imageView_nhl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="#drawable/nhl_btn" />
<TextView
android:id="#+id/textView_chooseteam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="d"
android:textColor="#color/gray"
android:textSize="10sp"
android:visibility="invisible" />
</LinearLayout>
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:text="#string/Games_Placebet_chooseteam"
android:textColor="#color/gray"
android:textSize="12sp"
android:visibility="invisible" />
</LinearLayout>
<LinearLayout
android:id="#+id/middle_line"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/first_view"
android:orientation="vertical" >
<ImageView
android:id="#+id/small_line"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="#drawable/small_line" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:text="f"
android:textColor="#color/gray"
android:textSize="5sp"
android:visibility="invisible" />
</LinearLayout>
<LinearLayout
android:id="#+id/list_header_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/middle_line" >
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dd"
android:textColor="#color/gray"
android:textSize="14sp"
android:visibility="invisible" />
<TextView
android:id="#+id/list_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Recent Activities"
android:textColor="#color/gray"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/list_header_layout" >
<ExpandableListView
android:id="#id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/first_view"
android:cacheColorHint="#00000000"
android:childDivider="#android:color/black"
android:divider="#android:color/black"
android:fadingEdge="none"
android:scrollingCache="false" >
</ExpandableListView>
</LinearLayout>
</RelativeLayout>
//settings Second view Setting
<RelativeLayout
android:id="#+id/progressrelative"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center_vertical|center_horizontal" >
<ProgressBar
android:id="#+id/progressbar2"
style="#android:style/Widget.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center_vertical|center_horizontal"
android:indeterminate="true"
android:visibility="gone" />
<ListView
android:id="#+id/channellist"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/frameLayout"
android:layout_below="#+id/header_relativelayout"
android:cacheColorHint="#00000000"
android:divider="#android:color/transparent"
android:fadingEdge="none"
android:scrollingCache="false" >
</ListView>
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="#+id/betView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="8dp" >
<TextView
android:id="#+id/textView_chooseteam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:text="#string/Games_Placebet_chooseteam"
android:textColor="#color/gray"
android:textSize="16sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/gm4_headar_parch"
android:gravity="center" >
<TextView
android:id="#+id/button_date_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:text="Saturday, 10/27/2012 at 01:00 PM"
android:textColor="#color/white"
android:textSize="13sp" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginTop="-5dp"
android:background="#drawable/gm4_1white_bg"
android:orientation="vertical"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
<TextView
android:id="#+id/button_hometeam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:clickable="true"
android:text="Denver Broncos"
android:textColor="#color/gray"
android:textSize="16sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView_button_hometeam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="#drawable/game_click_btn" />
</RelativeLayout>
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_marginTop="8dp"
android:background="#drawable/recent_bigpatch_line" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
<TextView
android:id="#+id/button_visitorteam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="SD Chargers"
android:textColor="#color/gray"
android:textSize="16sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/imageView_button_visitorteam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="#drawable/game_unclick_btn" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="5dp"
android:text="Betting Amount"
android:textColor="#color/gray"
android:textSize="16sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/upper_relative"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/gm4_headar_parch"
android:orientation="horizontal"
android:paddingLeft="8dp"
android:paddingRight="8dp" >
<TextView
android:id="#+id/textView_placebet_balance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:paddingTop="2dp"
android:text="#string/Games_Placebet_balance"
android:textColor="#android:color/white"
android:textSize="16sp"
android:textStyle="bold" />
<!--
<TextView
android:id="#+id/textView_placebet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingRight="32dp"
android:paddingTop="4dp"
android:text="$"
android:textColor="#android:color/white"
android:textStyle="bold" />
-->
<TextView
android:id="#+id/textView_placebet_dollar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingRight="10dp"
android:paddingTop="4dp"
android:text="100"
android:textColor="#android:color/white"
android:textStyle="bold" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="-5dp"
android:background="#drawable/gm4_1white_bg"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp" >
<TextView
android:id="#+id/button_placebet_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Denver Broncos"
android:textColor="#color/gray"
android:textSize="16sp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="10dp"
android:background="#drawable/recent_bigpatch_line" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="3dp"
android:layout_marginTop="10dp" >
<Button
android:id="#+id/button_placebet_up_counter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:background="#drawable/pg_2_up_arrow_btn" />
<Button
android:id="#+id/textview_placebet_counter_digipanel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:background="#drawable/counter_digitaldisplay"
android:textColor="#109EE6" />
<Button
android:id="#+id/button_placebet_counter_down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:background="#drawable/pg_2_down_arrow_btn" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<Button
android:id="#+id/button_betaganist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:background="#drawable/bet_against_btn_new"
android:gravity="center_horizontal|center_vertical"
android:paddingBottom="5dp"
android:text="#string/Games_Placebet_betaganist"
android:textColor="#color/white"
android:textSize="18sp"
android:textStyle="bold" />
<Button
android:id="#+id/button_placebet"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#drawable/placebet_btn_new"
android:gravity="center_horizontal|center_vertical"
android:paddingBottom="5dp"
android:text="Place Bet"
android:textColor="#android:color/white"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<ListView
android:id="#+id/friendlist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/frameLayout"
android:layout_below="#+id/header_relativelayout"
android:cacheColorHint="#00000000"
android:divider="#android:color/transparent"
android:fadingEdge="none"
android:scrollingCache="false" >
</ListView>
</ViewFlipper>
here is a code of xml file in which i have used viewflipper and in that i have added views so the first view is image view on upper side listview on the lower side when we click on image view next view will flip and so on... but in the first view it is scrolling only listview part i need to scroll whole view with single scroll.
THanks in advance..
The issue is, all the possible ways to mix in two scrolls does not yield well ( to best of my knowledge), Setting the header xml is probably the best approach for it. try to find a way around the situation.