I have been having problems with my table alignment which I can't fix. It's driving me crazy trying to fix this layout. Here's my main.xml:
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow>
<TextView
android:layout_width="40sp"
android:layout_marginTop="30dp"
android:text="From" />
<EditText
android:id="#+id/input"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:ems="10"
android:inputType="numberDecimal|numberSigned" >
<requestFocus />
</EditText>
</TableRow>
<Spinner
android:id="#+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="To" />
<Spinner
android:id="#+id/spinner2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TableRow>
<Button
android:id="#+id/button1"
android:layout_marginLeft="50dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="Formula" />
<Button
android:id="#+id/button1"
android:layout_marginRight="10dp"
android:layout_width="80dp"
android:layout_column="1"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="Convert" />
</TableRow>
<TextView
android:id="#+id/output"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/op"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall" />
</TableLayout>
I want it to look like this:
image link here http://imageshack.us/a/img818/5928/3wo5.png
try this
the layout is in there.
Related
I'm trying to insert some pixel art for my app as an ImageView, but it's very stubborn once I have it in. Specifically, it's centered and pretty much locked into a grid.
I would like to naturally place the sprite where I want to instead of having it snap to a grid. Any suggestions? Here it is:
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/cloud1" />
EDIT: Full XML
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:gravity="center"
android:text="Enter Two Numbers"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="bold" />
<EditText
android:id="#+id/editOp1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:ems="10"
android:inputType="numberDecimal" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/editOp2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal" />
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:gravity="center" >
<ImageButton
android:id="#+id/btnAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:src="#drawable/sun" />
<Button
android:id="#+id/btnSubtract"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textStyle="bold" />
<Button
android:id="#+id/btnDivide"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/"
android:textStyle="bold" />
<Button
android:id="#+id/btnMultiply"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="*"
android:textStyle="bold" />
<Button
android:id="#+id/clear"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CLR" />
</TableRow>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:gravity="center"
android:text="RESULT"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="0.00"
android:textAppearance="?android:attr/textAppearanceLarge" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:src="#drawable/grass" />
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/imageView2"
android:src="#drawable/grass" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/imageView3"
android:src="#drawable/grass" />
<ImageView
android:id="#+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/imageView4"
android:layout_marginLeft="12dp"
android:layout_marginTop="14dp"
android:src="#drawable/cloud2" />
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="43dp"
android:src="#drawable/cloud1" />
</RelativeLayout>
All you wanted to do is make the xml layout root as RelativeLayout & Go to Design tab, drag to where ever you want it to be.
Hope it helps!
The next code is OK for Eclipse Layout Editor and Android Studio. I tested it in several mobiles and works fine but, in a Samsung GT-S6310N (Android 4.1.2), this EditText dissapears. It goes at the end of a LinearLayout that defines the Layout width. The Layout is showed in a Dialog using android:Theme.Dialog.
<EditText
android:id="#+id/et_clino"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="4"
android:inputType="numberDecimal"
android:text="89.9" />
I've solved this changing the code to:
<EditText
android:id="#+id/et_clino"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="4"
android:inputType="numberDecimal"
android:text="89.9" />
The question is: is wrong mi code or is a bug?
This is the code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/LinearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp"
tools:context=".Measure" >
<RelativeLayout
android:id="#+id/rl_a"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/TextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignBaseline="#+id/et_from"
android:text="#string/from"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/et_from"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/TextView1"
android:ems="7"
android:hint="#string/from"
android:lines="1"
android:maxLength="7"
android:minLines="1"
android:nextFocusDown="#+id/et_to"
android:text="1234567" />
<EditText
android:id="#+id/et_to"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/et_from"
android:layout_alignParentRight="true"
android:ems="7"
android:hint="#string/to"
android:maxLength="7"
android:maxLines="1"
android:nextFocusDown="#+id/et_distance"
android:text="1234567" />
<TextView
android:id="#+id/TextView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/et_from"
android:layout_toLeftOf="#+id/et_to"
android:text="#string/to"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
<LinearLayout
android:id="#+id/ll_b"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/tv_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/distance_abr"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/green" />
<EditText
android:id="#+id/et_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="4"
android:hint="#string/distance_abr"
android:inputType="numberDecimal"
android:lines="5"
android:maxLength="6"
android:nextFocusDown="#+id/et_rumbomag" />
<TextView
android:id="#+id/TextView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/rumbo_mn_abr"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/et_rumbomag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="4"
android:hint="#string/rumbo_mn_abr"
android:inputType="numberDecimal"
android:maxLength="5"
android:nextFocusDown="#+id/et_measured_clino"
android:text="360.0" />
<TextView
android:id="#+id/tv_clino"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/clino"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/et_clino"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="4"
android:inputType="numberDecimal"
android:text="89.9" />
<!-- Así produce error: el et_clino desaparece y el tv_clino se estrecha y muestra el texto en 3 líneas
<EditText
android:id="#+id/et_clino"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="4"
android:inputType="numberDecimal"
android:text="89.9" />
-->
</LinearLayout>
<LinearLayout
android:id="#+id/ll_d"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioGroup
android:id="#+id/rg_direction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/rb_direct"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:hint="#string/direction"
android:text="#string/direct" />
<RadioButton
android:id="#+id/rb_inverse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="#string/inverse" />
</RadioGroup>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" >
<!--
<Button
android:id="#+id/btn_get_from_bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BT"
android:textColor="#color/blue" />
-->
<Button
android:id="#+id/btn_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="#string/delete"
android:textColor="#color/red" />
<ImageButton
android:id="#+id/ib_disto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="#drawable/disto" />
<Button
android:id="#+id/btn_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="#string/save"
android:textColor="#color/green" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/ll_e"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/et_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/description" >
<requestFocus />
</EditText>
</LinearLayout>
I've made some changes (particularly the LinearLayout containing the cli_no EditText, #string and #drawable resources) in the xml file as below:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="#+id/rl_a"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/TextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/et_from"
android:layout_alignParentLeft="true"
android:text="#string/from"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/et_from"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/TextView1"
android:ems="7"
android:hint="#string/from"
android:lines="1"
android:maxLength="7"
android:minLines="1"
android:nextFocusDown="#+id/et_to"
android:text="1234567" />
<EditText
android:id="#+id/et_to"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/et_from"
android:layout_alignParentRight="true"
android:ems="7"
android:hint="#string/to"
android:maxLength="7"
android:maxLines="1"
android:nextFocusDown="#+id/et_distance"
android:text="1234567" />
<TextView
android:id="#+id/TextView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/et_from"
android:layout_toLeftOf="#+id/et_to"
android:text="#string/to"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
<LinearLayout
android:id="#+id/ll_b"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/tv_distance"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="distance_abr"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/green" />
<EditText
android:id="#+id/et_distance"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ems="4"
android:layout_weight="1"
android:hint="distance_abr"
android:inputType="numberDecimal"
android:lines="5"
android:maxLength="6"
android:nextFocusDown="#+id/et_rumbomag" />
<TextView
android:id="#+id/TextView3"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="distance_abr"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/et_rumbomag"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:ems="4"
android:hint="rumbo"
android:inputType="numberDecimal"
android:maxLength="5"
android:text="360.0" />
<TextView
android:id="#+id/tv_clino"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="clino"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/et_clino"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="4"
android:inputType="numberDecimal"
android:text="89.9" />
</LinearLayout>
<LinearLayout
android:id="#+id/ll_d"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioGroup
android:id="#+id/rg_direction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/rb_direct"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:hint="direction"
android:text="direct" />
<RadioButton
android:id="#+id/rb_inverse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="inverse" />
</RadioGroup>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" >
<!--
<Button
android:id="#+id/btn_get_from_bt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BT"
android:textColor="#color/blue" />
-->
<Button
android:id="#+id/btn_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="#string/delete" />
<ImageButton
android:id="#+id/ib_disto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="#drawable/back02" />
<Button
android:id="#+id/btn_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="save"
android:textColor="#color/green" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/ll_e"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/et_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/description" >
<requestFocus />
</EditText>
</LinearLayout>
The reason for disappearing of the EditText is that you want to display items, which has total width greater than the width of the screen, so I've applied same layout_weight:"1" to all the elements inside the LinearLayout. May be this helps you for solving your issue.
i have a layout in my android project it takes input from edittext and sends the mail from this information but in layout the background does not show up on whole screen it leaves some space at the bottom so it do not look good
this is my layout:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbarStyle="insideOverlay"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="530dp"
android:background="#drawable/f4kf6msk"
android:fillViewport="true"
>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="#string/to"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#6495ed" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/to"
android:text="#string/app"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#6495ed" />
<EditText
android:id="#+id/from"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:textColor="#6495ed"
android:textStyle="bold"
android:layout_below="#+id/textView2"
android:ems="10"
android:hint="#string/from"
android:inputType="textEmailAddress" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/to"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/textView1"
android:ems="10"
android:textColor="#6495ed"
android:textStyle="bold"
android:hint="#string/too"
android:inputType="textEmailAddress"
/>
<Button
android:id="#+id/button1d"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/message"
android:background="#android:color/transparent"
android:gravity="center"
android:text="#string/send"
android:textColor="#6495ed" />
<View
android:id="#+id/View0dfd1"
android:layout_width="fill_parent"
android:layout_height="3dip"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#808080"
android:paddingBottom="3dp" />
<EditText
android:id="#+id/subject"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textView3"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="23dp"
android:textColor="#6495ed"
android:hint="#string/sub1"
android:textStyle="bold"
android:ems="10" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/from"
android:text="#string/sub"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#6495ed"
android:textStyle="bold" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/textView5"
android:layout_marginTop="39dp"
android:text="#string/Message"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#6495ed"
android:textStyle="bold" />
<EditText
android:id="#+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/subject"
android:ems="10"
android:gravity="top"
android:hint="#string/mess"
android:inputType="textMultiLine"
android:lines="11"
android:textColor="#6495ed"
android:textStyle="bold" />
<View
android:id="#+id/View0sd1"
android:layout_width="fill_parent"
android:layout_height="3dip"
android:layout_alignParentLeft="true"
android:layout_alignTop="#+id/button1d"
android:layout_marginTop="14dp"
android:background="#808080"
android:paddingBottom="3dp" />
</RelativeLayout>
</ScrollView>
try to put backround in scroll view property instead in relative layout
For app having:
Target: API 8 or Android Froyo.
The emulator: Android GingerBread 2.0.3.
App reads the data from the file from /sdcard which is supposed to be shown in Gridview layouts. But, in runtime the arrangement is distorted in landscape and portrait layout orientations.
The layout seems perfect while design time as in Image#1, but during the run time it is as seen in the Image#2.
And here is my XML for the Layout for landscape orientation:
<LinearLayout
android:id="#+id/LinearLayoutInside"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/button2"
android:orientation="vertical"
android:background="#drawable/border_bkgrnd" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3" >
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/TextView12"
android:layout_below="#+id/TextView12"
android:onClick="newActivity"
android:text="Medium Text"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp"
tools:ignore="HardcodedText" />
<TextView
android:id="#+id/TextView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView11"
android:layout_alignRight="#+id/textView11"
android:layout_alignTop="#+id/TextView22"
android:onClick="newActivity"
android:text="Medium Text"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp" />
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/txtTitlev1"
android:layout_below="#+id/txtTitlev1"
android:onClick="newActivity"
android:text="Medium Text"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3" >
<TextView
android:id="#+id/TextView31"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/txtTitlev3"
android:layout_alignParentRight="true"
android:layout_below="#+id/txtTitlev3"
android:text="#string/strNA"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp" />
<TextView
android:id="#+id/TextView33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/TextView23"
android:layout_alignBottom="#+id/TextView23"
android:layout_alignLeft="#+id/TextView32"
android:layout_alignParentRight="true"
android:text="#string/strNA"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp"
tools:ignore="HardcodedText" />
<TextView
android:id="#+id/txtTitlev1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/TextView21"
android:layout_alignParentLeft="true"
android:fontFamily="Roboto-BoldCondensed.ttf"
android:text="#string/ttlLeadid"
android:textColor="#color/Turquoise4"
android:layout_weight="1"
android:textSize="20sp"
android:textStyle="bold|normal"
android:typeface="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3" >
<TextView
android:id="#+id/TextView32"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/TextView31"
android:layout_alignParentRight="true"
android:layout_below="#+id/TextView31"
android:text="#string/strNA"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp"
tools:ignore="HardcodedText" />
<TextView
android:id="#+id/TextView22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/TextView21"
android:layout_below="#+id/TextView21"
android:text="Medium Text"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp"
tools:ignore="HardcodedText" />
<TextView
android:id="#+id/TextView23"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/TextView22"
android:layout_below="#+id/TextView22"
android:onClick="newActivity"
android:text="Medium Text"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp"
tools:ignore="HardcodedText" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3" >
<TextView
android:id="#+id/txtTitlev3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:fontFamily="Roboto-BoldCondensed.ttf"
android:text="#string/ttlContact"
android:textColor="#color/Turquoise4"
android:textSize="20sp"
android:layout_weight="1"
android:textStyle="bold|normal" />
<TextView
android:id="#+id/txtTitlev2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:fontFamily="Roboto-BoldCondensed.ttf"
android:text="#string/ttlName"
android:textColor="#color/Turquoise4"
android:textSize="20sp"
android:layout_weight="1"
android:textStyle="bold|normal" />
<TextView
android:id="#+id/TextView21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/TextView32"
android:layout_centerHorizontal="true"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp"
android:layout_weight="1"
tools:ignore="HardcodedText" />
</LinearLayout>
</LinearLayout>
[EDIT]
Is there any other alternative for arrangement?
Thanks in advance...
why dont you try using it through the RelativeLayout.layoutparams and the relative layout java coding.
you can do this using any layout for example here i am using a linear layout
Textview hname, game,time;
hname = new TextView(context);
game =new TextView(context);
time = new TextView(context);
LinearLayout ll = new LinearLayout(context);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(600, 100);
//add the settext here for ur textviews
ll.addView(hname, lp);
ll.addView(game, lp);
ll.addView(time, lp);
setcontentview(ll);
Try doing this with your RelativeLayout. I added 4 LinearLayouts in your RelativeLayout, all with a weightSum of 3 and moved your TextViews accordingly. I also set their layout_weight parameters to 1 so that they will be stretched across the screen.
I did not test this but it should work.
EDIT : I changed the RelativeLayout to a LinearLayout seeing that all your views are below eachother
<LinearLayout
android:id="#+id/LinearLayoutInside"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/button2"
android:orientation="vertical"
android:background="#drawable/border_bkgrnd" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3" >
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/TextView12"
android:layout_below="#+id/TextView12"
android:onClick="newActivity"
android:text="Medium Text"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp"
tools:ignore="HardcodedText" />
<TextView
android:id="#+id/TextView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView11"
android:layout_alignRight="#+id/textView11"
android:layout_alignTop="#+id/TextView22"
android:onClick="newActivity"
android:text="Medium Text"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp" />
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/txtTitlev1"
android:layout_below="#+id/txtTitlev1"
android:onClick="newActivity"
android:text="Medium Text"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3" >
<TextView
android:id="#+id/TextView31"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/txtTitlev3"
android:layout_alignParentRight="true"
android:layout_below="#+id/txtTitlev3"
android:text="#string/strNA"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp" />
<TextView
android:id="#+id/TextView33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/TextView23"
android:layout_alignBottom="#+id/TextView23"
android:layout_alignLeft="#+id/TextView32"
android:layout_alignParentRight="true"
android:text="#string/strNA"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp"
tools:ignore="HardcodedText" />
<TextView
android:id="#+id/txtTitlev1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/TextView21"
android:layout_alignParentLeft="true"
android:fontFamily="Roboto-BoldCondensed.ttf"
android:text="#string/ttlLeadid"
android:textColor="#color/Turquoise4"
android:layout_weight="1"
android:textSize="20sp"
android:textStyle="bold|normal"
android:typeface="normal" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3" >
<TextView
android:id="#+id/TextView32"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/TextView31"
android:layout_alignParentRight="true"
android:layout_below="#+id/TextView31"
android:text="#string/strNA"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp"
tools:ignore="HardcodedText" />
<TextView
android:id="#+id/TextView22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/TextView21"
android:layout_below="#+id/TextView21"
android:text="Medium Text"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp"
tools:ignore="HardcodedText" />
<TextView
android:id="#+id/TextView23"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/TextView22"
android:layout_below="#+id/TextView22"
android:onClick="newActivity"
android:text="Medium Text"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp"
tools:ignore="HardcodedText" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3" >
<TextView
android:id="#+id/txtTitlev3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:fontFamily="Roboto-BoldCondensed.ttf"
android:text="#string/ttlContact"
android:textColor="#color/Turquoise4"
android:textSize="20sp"
android:layout_weight="1"
android:textStyle="bold|normal" />
<TextView
android:id="#+id/txtTitlev2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:fontFamily="Roboto-BoldCondensed.ttf"
android:text="#string/ttlName"
android:textColor="#color/Turquoise4"
android:textSize="20sp"
android:layout_weight="1"
android:textStyle="bold|normal" />
<TextView
android:id="#+id/TextView21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/TextView32"
android:layout_centerHorizontal="true"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15sp"
android:layout_weight="1"
tools:ignore="HardcodedText" />
</LinearLayout>
</LinearLayout>
You can use a layout something like this. I used table layout with 3 rows. The first row shows column heading and other rows shows data.
<?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="wrap_content"
android:layout_gravity="center"
android:stretchColumns="*" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp" >
<TextView
android:id="#+id/ID"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ID"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Contact"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="12"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name 1"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1234567"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="25"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name 2"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="594751"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
</TableLayout>
</LinearLayout>
Below given is my layout which is I am using for displaying a table, which have a number of rows. the problem is this table have more no of rows than the screen can contain, so i want rows to be scrollable so that if i scroll down i can reach to the rows which is not visible in current screen.
i used isScrollContainer="true" bur this does not solve my problem
Can you please suggest which property can i use to solve the problem
<TableLayout android:layout_height="wrap_content" android:isScrollContainer="true" >
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content" android:gravity="center">
<View android:layout_gravity="center" android:layout_height="30px"
android:background="#android:color/darker_gray"
android:layout_width="400px" />
<TextView android:layout_width="wrap_content" style="#style/styleName"
android:id="#+id/tv_add_ticket" android:text="Update Ticket on Assembloid Space"
android:layout_height="wrap_content" android:layout_marginLeft="5px"
android:layout_marginRight="2px" android:layout_marginTop="2px"
android:layout_marginBottom="2px">
</TextView>
</RelativeLayout>
</TableLayout>
<TableLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20px" android:isScrollContainer="true"
xmlns:android="http://schemas.android.com/apk/res/android"
android:baselineAligned="true" android:background="#565051"
android:layout_marginTop="50px">
<TableRow>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/ticket_status"
android:text="Status " android:layout_column="1" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text=":"
android:layout_column="2" android:layout_marginTop="5px"
android:layout_marginRight="5px" />
<!-- <EditText android:layout_width="250px" android:layout_height="wrap_content"
android:id="#+id/et_ticket_status"></EditText> -->
<Spinner android:layout_width="100px" android:layout_height="wrap_content"
android:id="#+id/spn_up_ticket_status"></Spinner>
</TableRow>
<TableRow>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/ticket_priority"
android:text="Priority" android:layout_column="1" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text=":"
android:layout_column="2" android:layout_marginTop="5px"
android:layout_marginRight="5px" />
<Spinner android:layout_width="200px" android:layout_height="wrap_content"
android:id="#+id/spn_up_ticket_priority"></Spinner>
</TableRow>
<TableRow>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/ticket_summary"
android:text="Summary" android:layout_column="1" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text=":"
android:layout_column="2" android:layout_marginTop="5px"
android:layout_marginRight="5px" />
/>
<EditText android:layout_width="250px" android:id="#+id/et_ticket_summary"
android:layout_height="wrap_content" android:autoText="true">
</EditText>
</TableRow>
<TableRow>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/ticket_discription"
android:text="Discription" android:layout_column="1" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text=":"
android:layout_column="2" android:layout_marginTop="5px"
android:layout_marginRight="5px" />
/>
<EditText android:layout_width="250px" android:id="#+id/et_ticket_Discription"
android:layout_height="wrap_content" android:autoText="true"></EditText>
</TableRow>
<TableRow>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/estimated_hour"
android:text="Estimated Hours" android:layout_column="1" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text=":"
android:layout_column="2" android:layout_marginTop="5px"
android:layout_marginRight="5px" />
/>
<EditText android:layout_width="250px" android:id="#+id/et_estimated_hour"
android:layout_height="wrap_content" android:autoText="true"></EditText>
</TableRow>
<TableRow>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/worked_hour"
android:text="Worked Hours" android:layout_column="1" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text=":"
android:layout_column="2" android:layout_marginTop="5px"
android:layout_marginRight="5px" />
<EditText android:layout_width="250px" android:id="#+id/et_worked_hour"
android:layout_height="wrap_content" android:autoText="true"></EditText>
</TableRow>
<TableRow>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/ticket_comment"
android:text="Comment" android:layout_column="1" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text=":"
android:layout_column="2" android:layout_marginTop="5px"
android:layout_marginRight="5px" />
/>
<EditText android:layout_width="250px" android:id="#+id/et_ticket_comment"
android:layout_height="wrap_content" android:autoText="true">
</EditText>
</TableRow>
<TableRow>
<Button android:layout_width="wrap_content" android:text="Comments"
android:layout_height="wrap_content" android:id="#+id/comment_ticket_button" android:layout_column="1" ></Button>
<Button android:layout_width="wrap_content" android:text="#string/update_ticket"
android:layout_height="wrap_content" android:id="#+id/update_ticket_button" android:layout_column="3"></Button>
</TableRow>
<TextView android:id="#+id/error_ticket_text"
android:layout_centerHorizontal="true" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_below="#+id/login_button" />
You should wrap your TableLayout inside a ScrollView with appropriate height
<ScrollView android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="100dp">
<TableLayout..>
</TableLayout>
</ScrollView>
You should use ScrollView as the root layout to solve your problem.