I'm trying to put a TextView into my TableView so that it doesn't push the spinner box and the other TextView off of the screen. I've tried changing the layout_width, yet that has not worked. I have also tried changing the layout_width of the TableRow, but that is not working, either. So how can I fit the text of the left-most textView in the row?
<TableLayout android:id="#+id/abilityScoreTable"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android" android:padding="0dip">
<TextView android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_width="wrap_content" android:gravity="center" android:textSize="30dip" android:id="#+id/abilityScoreBannerText" android:text="Ability Scores"></TextView>
<TableRow android:layout_width="wrap_content" android:gravity="center" android:id="#+id/tableRow1" android:layout_height="wrap_content">
<TextView android:text="zero" android:id="#+id/StrengthBonusText" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<Spinner android:id="#+id/StrengthSpinner" android:layout_width="10px" android:layout_height="wrap_content" android:entries="#array/string_ability_scores"></Spinner>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" android:id="#+id/StrengthTextView" android:text="Strength"
android:textSize="30dip"></TextView>
</TableRow>
<TableRow android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="#+id/tableRow2" android:gravity="center">
<Spinner android:layout_height="wrap_content" android:layout_width="wrap_content"
android:id="#+id/dexteritySpinner" android:entries="#array/string_ability_scores"></Spinner>
<TextView android:id="#+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Dexterity" android:textSize="30dip"></TextView>
</TableRow>
<TableRow android:layout_width="wrap_content" android:layout_height="wrap_content"
android:entries="#array/string_ability_scores" android:layout_gravity="center"
android:gravity="center" android:id="#+id/TableRow3">
<Spinner android:id="#+id/ConstitutionSpinner"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:entries="#array/string_ability_scores"></Spinner>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Constitution" android:textSize="30dip"
android:id="#+id/ConstitutionTextView"></TextView>
</TableRow>
<TableRow android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="#+id/tableRow3" android:gravity="center">
<Spinner android:layout_height="wrap_content"
android:id="#+id/intelligenceSpinner"
android:layout_width="wrap_content"
android:entries="#array/string_ability_scores"></Spinner>
<TextView android:id="#+id/textView1"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Intelligence" android:textSize="30dip"></TextView>
</TableRow>
<TableRow android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="#+id/tableRow4"
android:gravity="center">
<Spinner android:layout_height="wrap_content"
android:id="#+id/WisdomSpinner" android:layout_width="wrap_content"
android:entries="#array/string_ability_scores"></Spinner>
<TextView android:id="#+id/textView3"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" android:text="Wisdom"
android:textSize="30dip"></TextView>
</TableRow>
<TableRow android:layout_height="wrap_content"
android:layout_width="wrap_content" android:id="#+id/tableRow5"
android:gravity="center">
<Spinner android:layout_height="wrap_content"
android:id="#+id/CharismaSpinner" android:layout_width="wrap_content"
android:entries="#array/string_ability_scores"></Spinner>
<TextView android:id="#+id/textView4"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Charisma" android:textSize="30dip"></TextView>
</TableRow>
</TableLayout>
Currently, it looks like this:
On the top-most spinner there's suppose to be a number to the left. I'm trying to squeeze it on to the screen and have all three fit.
im not sure what you want any way check this and tell me is this what you are trying.
if so here is the xml.
<TableRow android:id="#+id/tableRow1">
<TextView android:text="zero" android:id="#+id/StrengthBonusText"></TextView>
<Spinner android:id="#+id/StrengthSpinner" />
<TextView android:id="#+id/StrengthTextView"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Strength" android:textSize="30dip" />
</TableRow>
<TableRow android:id="#+id/tableRow2">
<View android:visibility="invisible" android:layout_height="0dip" />
<Spinner android:id="#+id/dexteritySpinner" />
<TextView android:id="#+id/textView2" android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Dexterity" android:textSize="30dip" />
</TableRow>
<TableRow android:id="#+id/TableRow3">
<View android:visibility="invisible" android:layout_height="0dip" />
<Spinner android:id="#+id/ConstitutionSpinner"></Spinner>
<TextView android:id="#+id/ConstitutionTextView"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Constitution" android:textSize="30dip"></TextView>
</TableRow>
<TableRow android:id="#+id/tableRow3">
<View android:visibility="invisible" android:layout_height="0dip"/>
<Spinner android:id="#+id/intelligenceSpinner"></Spinner>
<TextView android:id="#+id/textView1" android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Intelligence" android:textSize="30dip"></TextView>
</TableRow>
<TableRow android:id="#+id/tableRow4">
<View android:visibility="invisible" android:layout_height="0dip"/>
<Spinner android:id="#+id/WisdomSpinner"></Spinner>
<TextView android:id="#+id/textView3" android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Wisdom" android:textSize="30dip"></TextView>
</TableRow>
<TableRow android:id="#+id/tableRow5">
<View android:visibility="invisible" android:layout_height="0dip"/>
<Spinner android:id="#+id/CharismaSpinner"></Spinner>
<TextView android:id="#+id/textView4" android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Charisma" android:textSize="30dip"></TextView>
</TableRow>
Have you tried using a relative layout or is that just not an option? Also I noticed you are mixing px and dip - this is usually not recommended
Related
I am new to android. I am creating following layout design in android. but it not adapt to all type of screen resolution on different mobile device such as Nexus 4,Nexus 7, 3.2in HVGA slider(ADP1). The layout of the screen is changes. how to solve the problem. This is my layout code..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="#drawable/home" android:layout_height="match_parent"
android:orientation="vertical">
<TableRow android:id="#+id/tableRow4" android:padding="20dp" android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView android:text="USER LOGIN" android:textColor="#0000ff" android:textStyle="bold" android:paddingLeft="30dp" android:textSize="32dp" android:id="#+id/textView4" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
</TableRow>
<TableRow android:id="#+id/tableRow1" android:padding="5dp" android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView android:text="NAME" android:textColor="#ff0000" android:textStyle="bold" android:textSize="24dp" android:paddingRight="5dp" android:id="#+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<EditText android:text=" " android:id="#+id/loginnew_name_editText1" android:layout_width="fill_parent" android:layout_height="wrap_content"></EditText>
</TableRow>
<TableRow android:id="#+id/tableRow1" android:padding="5dp" android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView android:text="AGE " android:textColor="#ff0000" android:textStyle="bold" android:textSize="24dp" android:paddingRight="5dp" android:id="#+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<EditText android:text=" " android:id="#+id/loginnew_age_editText2" android:layout_width="fill_parent" android:layout_height="wrap_content"></EditText>
</TableRow>
<RelativeLayout android:layout_width="match_parent" android:id="#+id/relativeLayout1" android:layout_height="wrap_content">
<TextView android:text="GENDER" android:textColor="#ff0000" android:textStyle="bold" android:paddingRight="5dp" android:textSize="24dp" android:id="#+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
<RadioGroup android:id="#+id/radioGroup1" android:paddingLeft="100dp" android:layout_width="wrap_content" android:layout_height="wrap_content">
<RadioButton android:layout_height="wrap_content" android:textColor="#ff0000" android:layout_width="wrap_content" android:id="#+id/loginnew_male_radio0" android:checked="true"></RadioButton>
<RadioButton android:layout_height="wrap_content" android:textColor="#ff0000" android:layout_width="wrap_content" android:id="#+id/loginnew_female_radio1"></RadioButton>
</RadioGroup>
<ImageView android:id="#+id/imageView1" android:layout_width="wrap_content" android:padding="5dp" android:layout_height="wrap_content" android:src="#drawable/ast" android:layout_toRightOf="#+id/radioGroup1" android:layout_alignTop="#+id/radioGroup1"></ImageView>
<ImageView android:id="#+id/imageView2" android:layout_width="wrap_content" android:padding="5dp" android:layout_height="wrap_content" android:src="#drawable/dora" android:layout_below="#+id/imageView1" android:layout_alignLeft="#+id/imageView1" android:layout_alignRight="#+id/imageView1"></ImageView>
</RelativeLayout>
<TableRow android:layout_height="wrap_content" android:paddingLeft="20dp" android:paddingRight="20dp" android:layout_alignParentBottom="true" android:id="#+id/tableRow1" android:layout_width="fill_parent">
<Button android:text="SAVE" android:id="#+id/loginnew_save_button1" android:textStyle="bold" android:background="#drawable/brand_button_bg" android:textColor="#ffffff00" android:textSize="28dp" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
</TableRow>
</LinearLayout>
As shown in the image i want to reduce the gap between two rows (marked by red color) so that my edit text appears just below the text.
My code
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dip" >
<TextView
android:id="#+id/textView1"
android:text="#string/projectName"
android:textSize="16sp"
android:textAppearance="#string/projectName"
android:textColor="#color/text_color"/>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dip">
<EditText
android:id="#+id/editText"
android:layout_width="0dp"
android:layout_height="35dp"
android:inputType="text"
android:singleLine="true"
android:background="#drawable/editbox_background_normal"
android:layout_weight="1"
android:padding="5dip"
/>
</TableRow>
</TableLayout>
Get rid of all those paddings
android:padding="2dip"
android:padding="5dip"
You can use padding left and right instead.
Try this
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:id="#+id/textView1"
android:text="#string/projectName"
android:textSize="16sp"
android:textAppearance="#string/projectName"
android:textColor="#color/text_color"/>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<EditText
android:id="#+id/editText"
android:layout_width="0dp"
android:layout_height="35dp"
android:inputType="text"
android:singleLine="true"
android:background="#drawable/editbox_background_normal"
android:layout_weight="1"
/>
</TableRow>
</TableLayout>
Buddy try this,it must help you
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dip"
android:layout_marginBottom="10dp">
<TextView
android:id="#+id/textView1"
android:text="#string/projectName"
android:textSize="16sp"
android:textAppearance="#string/projectName"
android:textColor="#color/text_color"/>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dip"
android:layout_marginTop="10dp">
<EditText
android:id="#+id/editText"
android:layout_width="0dp"
android:layout_height="35dp"
android:inputType="text"
android:singleLine="true"
android:background="#drawable/editbox_background_normal"
android:layout_weight="1"
android:padding="5dip"
/>
</TableRow>
</TableLayout>
I have a LinearLayout with TableLayout and LinearLayout inside. TableLayout is made up of 5 TableRows. Each TableRow is made up of two View objects.
Firt column has two TextViews, my problem is that the text of TexView is wrapped:
The word SomeValue is wrapped, the letter e is a in new line, I'd like all in just one row, in this case and in general case, wath's the way pattern?
For example:
<?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:gravity="center"
android:orientation="vertical"
android:padding="#dimen/padding_small"
android:id="#+id/layout1">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal|top"
android:stretchColumns="0,true"
android:shrinkColumns="*,true">
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Value1"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Spinner
android:id="#+id/spinnerPrefix"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
**<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SomeValue"
android:textAppearance="?android:attr/textAppearanceSmall" />
<EditText
android:id="#+id/valueU"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="phone" >
<requestFocus />
</EditText>
</TableRow>**
<TableRow
android:id="#+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Mytext"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
<EditText
android:id="#+id/valueN"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10" />
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AnyValue"
android:textAppearance="?android:attr/textAppearanceSmall" />
<DatePicker
android:id="#+id/datePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:id="#+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Some"
android:textAppearance="?android:attr/textAppearanceSmall" />
<RadioGroup
android:id="#+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<RadioButton
android:id="#+id/radioM"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="M" />
<RadioButton
android:id="#+id/radioF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="F" />
</RadioGroup>
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingTop="#dimen/padding_small" >
<Button
android:id="#+id/buttonRegistrazione"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send Data" />
</LinearLayout>
</LinearLayout>
For each textview you could add
android:singleLine = "true"
That will make it a single line. If the text is too big then you could use ellipsize
android:ellipsize
to control how you want the text to appear
I created a TableLayout for my application. Everything is working fine, but once I add the button image at the bottom of the page the alignment breaks. Here is an image before entering the button image code:
After entering the code for the button images:
My xml layout:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:shrinkColumns="*"
android:stretchColumns="*"
android:background="#drawable/authenticinfo">
<TableRow
android:id="#+id/tableRow1"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="serif"
android:textSize="18dp"
android:gravity="center"
android:layout_span="6"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="serif"
android:textSize="38dp"
android:gravity="center"
android:layout_span="6"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="serif"
android:textSize="38dp"
android:gravity="center"
android:layout_span="6"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<ImageView
android:id="#+id/imview"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
/>
</TableRow>
<TableRow
android:id="#+id/tableRow5"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="serif"
android:textSize="20dp"
android:gravity="center"
></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow6"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:id="#+id/ProductID1"
android:text="Product ID"
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/ProductID2"
android:text=":"
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/ProductID3"
android:text="92173ad0"
android:textStyle="bold"
android:typeface="serif"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow7"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:id="#+id/ProductID4"
android:text="产品编号 "
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/ProductID5"
android:text=":"
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/ProductID6"
android:text="92173ad0"
android:textStyle="bold"
android:typeface="serif"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow8"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="serif"
android:textSize="8dp"
android:gravity="center"
android:layout_span="6"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow9"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:id="#+id/Manf1"
android:text="生产日期 "
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/Manf2"
android:text=":"
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/Manf3"
android:text="01 Jan 2012"
android:textStyle="bold"
android:typeface="serif"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow10"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:id="#+id/Exp1"
android:text="有效日期 "
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/Exp2"
android:text=":"
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/Exp3"
android:text="01 Jan 2015"
android:textStyle="bold"
android:typeface="serif"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow11"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="serif"
android:textSize="8dp"
android:gravity="center"
android:layout_span="6"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow12"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:id="#+id/Mas1"
android:text="马来西亚出口许可证 "
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/Mas2"
android:text=":"
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/Mas3"
android:text=""
android:textStyle="bold"
android:typeface="serif"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow13"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:id="#+id/China1"
android:text="中国的进口许可证 "
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/China2"
android:text=":"
android:textStyle="bold"
android:typeface="serif"></TextView>
<TextView
android:id="#+id/China3"
android:text=""
android:textStyle="bold"
android:typeface="serif"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow14"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:typeface="serif"
android:textSize="28dp"
android:gravity="center"
android:layout_span="6"></TextView>
</TableRow>
<TableRow
android:id="#+id/tableRow15"
>
<ImageView
android:id="#+id/imbutt"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:background="#+drawable/buttonmainmenuoff"
/>
<ImageView
android:id="#+id/imbutt"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:background="#+drawable/buttonmainmenuoff"
/>
<ImageView
android:id="#+id/imbutt"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:background="#+drawable/buttonmainmenuoff"
/>
</TableRow>
</TableLayout>
The layout breaks because the ImageViews that you add at the end stretch the columns where they are placed(for example the second ImageView that you add will stretch the TextView that holds the :). You don't say how you want them placed but one simple thing that you could do is to wrap them in another layout, like LinearLayout like this:
<TableRow android:id="#+id/tableRow15" >
<LinearLayout
android:layout_span="6"
android:gravity="center" >
<ImageView
android:id="#+id/imbutt1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher" />
<ImageView
android:id="#+id/imbutt2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher" />
<ImageView
android:id="#+id/imbutt3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher" />
</LinearLayout>
</TableRow>
Of course you could spread them if you want, with the layout_weight attribute.
As a side note, do you really have 6 columns in your layout(you set the layout_span to 6)? Also , do you use those empty singular TextViews or you just use them as dividers(if this is what you want, then you could consider a simple View element outside the TableRows with the desired height)?
Here is my code :
What i want is just to make scrollbar available in my application so that the overflow text
will be present in the screen.
Here i am using table layout and table row where my content is too long for a row and it will be long for height of screen so how to display horizontal and vertical scrollbar this code is not working
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbarAlwaysDrawHorizontalTrack="true"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbars="horizontal|vertical" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
<TextView
android:id="#+id/txtHeaderModels"
android:layout_width="100sp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#000000"
android:gravity="center_horizontal"
android:text="Demo"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="8pt" />
</TableRow>
</TableLayout>
You can try enclosing within both the scrolls like this,
<ScrollView>
<HorizontalScrollView>
<TableLayout>
<TableRow>
//Your Elements Here
</TableRow>
<TableLayout>
</HorizontalScrollView>
</ScrollView>
Use ScrollView. Here is the Reference link. ScrollView
Tutorial Here - http://www.vogella.de/articles/Android/article.html#scrollview
put your table layout inside a Horizontal Scroll view
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:scrollbars="horizontal">
</ScrollView>