I have a form using ScrollView. There are 2 spinners in the form and in portrait mode one of spinners goes out of the screen but in landscape view the spinner is visible. What setting needs to be changed so that spinner does not go out of the screen? (Comment- The label Select Month in the image should actually be "Select Month & Year" )
<?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="wrap_content"
android:textSize="20sp">
<!-- android:layout_width="wrap_content"
android:layout_height="match_parent"
-->
<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:background="#drawable/back"
android:scrollbars="vertical"
android:textSize="20sp">
<!--Month Combo Box-->
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select Month & Year"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<Spinner
android:id="#+id/spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<Spinner
android:id="#+id/spinneryr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#0c0b0b"
android:textSize="20sp" />
</TableRow>
<!--Field1 Combo Box-->
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/ERYTHROCYTE"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/ERYTHROCYTE"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:inputType="numberDecimal" />
</TableRow>
<!--Field2 Combo Box-->
<TableRow
android:id="#+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/HAEMOGLOBIN"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/HAEMOGLOBIN"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:inputType="numberDecimal" />
</TableRow>
<!--Field3 Combo Box-->
<TableRow
android:id="#+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/PCV"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/PCV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:inputType="numberDecimal" />
</TableRow>
<!--Field4 Combo Box-->
<TableRow
android:id="#+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/RDW"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/RDW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:inputType="numberDecimal" />
</TableRow>
<!--Field5 Combo Box-->
<TableRow
android:id="#+id/tableRow6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/MCV"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/MCV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:gravity="center"
android:inputType="numberDecimal" />
</TableRow>
<!--Field6 Combo Box-->
<TableRow
android:id="#+id/tableRow7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/MCH"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/MCH"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:inputType="numberDecimal" />
</TableRow>
<!--Field7 Combo Box-->
<TableRow
android:id="#+id/tableRow8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/MCHC"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/MCHC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:gravity="center"
android:inputType="numberDecimal" />
</TableRow>
<!--Field8 Combo Box-->
<TableRow
android:id="#+id/tableRow9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/LEUCOCYTECOUNT"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/LEUCOCYTECOUNT"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:gravity="center"
android:inputType="numberDecimal" />
</TableRow>
<!--Field9 Combo Box-->
<TableRow
android:id="#+id/tableRow10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/PLATELETS"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/PLATELETS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:gravity="center"
android:inputType="numberDecimal" />
</TableRow>
<!--Field10 Combo Box-->
<TableRow
android:id="#+id/tableRow11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/NEUTROPHILS"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/NEUTROPHILS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:gravity="center"
android:inputType="numberDecimal" />
</TableRow>
<!--Field11 Combo Box-->
<TableRow
android:id="#+id/tableRow12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/EOSINOPHILS"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/EOSINOPHILS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:gravity="center"
android:inputType="numberDecimal" />
</TableRow>
<!--Field12 Combo Box-->
<TableRow
android:id="#+id/tableRow13"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20sp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/LYMPHOCYTES"
android:textColor="#0c0b0b"
android:textSize="20sp" />
<EditText
android:id="#+id/LYMPHOCYTES"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back"
android:gravity="center"
android:inputType="numberDecimal" />
</TableRow>
<!-- Button :Start here-->
<TableRow
android:id="#+id/tableRow14"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20sp">
<Button
android:id="#+id/btnAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/add" />
<Button
android:id="#+id/btnViewAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/view_all" />
</TableRow>
<!--<Button
android:id="#+id/btnDelete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/delete" />
<Button
android:id="#+id/btnShowInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/show_info" />
</TableRow>-->
<!-- <TableRow
android:id="#+id/tableRow15"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20sp">
<Button
android:id="#+id/btnModify"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/modify" />
<Button
android:id="#+id/btnView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/view" />
<Button
android:id="#+id/btnShowInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/show_info" >
</TableRow-->
<TextView
android:id="#+id/tvValues"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="20sp" />
</TableLayout>
</ScrollView>
What setting needs to be changed so that spinner does not go out of the screen?
None. There's no settings for that - it's basically how you made your layout and it simply does not fit. You can consider having separate layout file for each orientation so you'd i.e. put spinners vertically for portrait layout -> just create layout-land in your res/ and copy current layout there. Then edit the one in layout to make it better fit the screen. That's it.
I am posting answer to my question. I managed to fix the issue by doing the following changes to ScrollView. After the change the TextView & both spinners are now visible on the same row and well aligned.
Code changes to ScrollView -
1) Updating android:layout_width="fill_parent"
2) Updating android:layout_height="fill_parent"
3) Adding android:fillViewport="true"
Code changes to TableLayout
1) Added android:layout_centerInParent="true"
2) Added android:gravity="center"
Solution suggested by #Marcin is another way (probably a more versatile solution) to solve the issue but since the above solution worked I did not try it.
Related
How to design the following as shown in the picture:
my xml structure is:
<Root>
<other design>
<need to design as in picture>
</Root>
the picture is :
that is the text should appear in left and right alignment.
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="HOUR"
android:textColor="#C0C0C0" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="$1.80"
android:textColor="#6686A8" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="DAY"
android:textColor="#C0C0C0" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="$10.00"
android:textColor="#6686A8" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="WEEK"
android:textColor="#C0C0C0" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="$35.00"
android:textColor="#6686A8" />
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="MONTH"
android:textColor="#C0C0C0" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="$105.00"
android:textColor="#6686A8" />
</TableRow>
</TableLayout>
You can use TableLayout to achieve that kind of layout.
Im new in andorid.I put textview to set data from mymethods.But it goes force close.But I tried it in another activity page my code worked.So ı suspected my xml layout .does anyone take care of this problem ,if so I will be very gratefull.Thanks Here are my layout.xml and my codes:
String iskate=WorkCat.Kategori(Workid);
iskat.setText(iskate);
Log.d("işkategorisi",iskate);
and Log.cat shows true value.
<?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="match_parent"
android:background="#drawable/backgrund" >
<!-- Header Starts -->
<LinearLayout
android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_alignParentTop="true"
android:background="#layout/header" >
</LinearLayout>
<!-- Header Ends -->
<!-- Footer Start -->
<LinearLayout
android:id="#+id/footer"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_alignParentBottom="true"
android:background="#layout/footer" >
<ImageView
android:id="#+id/imagegeri"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="220dp"
android:src="#drawable/geri" />
<ImageView
android:id="#+id/imagecikis"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/cikis" />
</LinearLayout>
<TextView
android:id="#+id/textAD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/header"
android:layout_alignParentRight="true"
android:layout_marginBottom="14dp"
android:layout_marginRight="26dp"
android:text="Small Text"
android:textSize="13dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#FFFFFF" />
<LinearLayout
android:id="#+id/content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#id/footer"
android:layout_below="#id/textAD" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#id/header"
android:orientation="vertical"
android:padding="10dip" >
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="İş Kategorisi"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
<TextView
android:id="#+id/txtiskate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="rfyr"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
</TableRow>
<TableRow>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Aşama"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
<Spinner
android:id="#+id/spinner2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" >
</Spinner>
</TableRow>
<TableRow>
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Görevli"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
<AutoCompleteTextView
android:id="#+id/Searchname"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</AutoCompleteTextView>
</TableRow>
<TableRow>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Öncelik"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
<Spinner
android:id="#+id/spinner3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" >
</Spinner>
</TableRow>
<EditText
android:id="#+id/edituacikla"
android:layout_width="290dp"
android:layout_height="140dp"
android:ems="10"
android:inputType="textMultiLine" />
<TableRow>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gerçekleşen Süre"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
<EditText
android:id="#+id/edittoplm"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView6"
android:layout_alignBottom="#+id/textView6"
android:layout_alignLeft="#+id/spinner4"
android:ems="10"/>
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Saat"
android:textAppearance="?android:attr/textAppearanceSmall" />
</TableRow>
<TableRow>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tamamlanan(%)"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#000000"
android:textStyle="bold" />
<Spinner
android:id="#+id/spinner5"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_alignParentLeft="true" >
</Spinner>
</TableRow>
<TableRow>
<Button
android:id="#+id/btnvzgec"
style="?android:attr/buttonStyleSmall"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="Vazgec" />
<Button
android:id="#+id/uwgncelle"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Güncelle" />
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
</RelativeLayout>
Initialize your Text View first
TextView iskat = (TextView)findViewById(R.id.txtiskate);
String iskate=WorkCat.Kategori(Workid);
iskat.setText(iskate);
First you need to initialize your textview then after you can use it. Try below code.
TextView iskat = (TextView)findViewById(R.id.txtiskate);
String iskate=WorkCat.Kategori(Workid);
iskat.setText(iskate);
'iskate' should be instance of a 'TextView' like iskate=(TextView)(TextView)findViewById(id of the layout in xml here);
in your case its a string how is this possible this will show compile time error.
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 am using Table Layout.
Here i have three EditText's with same width ="200dp".
But i want to increase the size of 3rd EditText.
I made its width="wrap_content" but all other EditText also getting "wrap_content"
How can i increase the width of 3rd EditText with out affecting other EditText's.
This code for 3rd EditText:-
<TableRow
android:gravity="center_horizontal"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:id="#+id/addl"
android:text="Address"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:id="#+id/colon"
android:text=":" />
<EditText
android:layout_width="250dp"
android:layout_marginLeft="20dp"
android:id="#+id/et"
android:singleLine="true"/>
</TableRow>
Now i want to increase width of Address EditText only
i think you can achieve this by layout_weight parameter of EditTexts like below
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relativeLayout12"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#909090"
android:padding="10dp" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Student ID"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="6" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="#000000" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Class"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="#000000" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Address"
android:textColor="#000000" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text=":"
android:textColor="#000000" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</TableRow>
</TableLayout>
EDIT
This is the outcome
put the property android:stretchColumns="2" in TableLayout
<TableLayout android:stretchColumns="2" ... > .... </TableLayout>
I'm creating an android application, which has a particular screen (layout) with over (120+ views), which generates the warning:
"main.xml has more than 80 views, bad for performance"
I have lots of TextViews, EditTexts, groups of RadioButtons organized on 26 TableRows.
Is there anything I can do to enhance application performance and remove warning?
source:
main.xml_capture
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LinearLayout00"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical" >
<TableRow
android:id="#+id/tableRow00"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right|top"
android:gravity="right" >
<Button
android:id="#+id/id_but_val"
android:layout_width="#dimen/button_width"
android:layout_height="wrap_content"
android:background="#drawable/button_colored"
android:text="#string/but_valid"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/id_but_up"
android:layout_width="#dimen/button_width"
android:layout_height="wrap_content"
android:background="#drawable/button_colored"
android:onClick="goToTop"
android:text="#string/but_ret_up"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="#+id/id_but_back"
android:layout_width="#dimen/button_width"
android:layout_height="wrap_content"
android:background="#drawable/button_colored"
android:text="#string/but_ret_back"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
<ScrollView
android:id="#+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:isScrollContainer="true"
android:overScrollMode="always"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbarStyle="outsideInset" >
<LinearLayout
android:id="#+id/LinearLayout01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical" >
<TableRow
android:id="#+id/TableRow01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/row_margin_top" >
<TextView
android:id="#+id/TextView01"
android:layout_width="#dimen/label_width"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/view_left_margin"
android:text="#string/ecran3_84_obstacles_acces" />
<RadioGroup
android:id="#+id/RadioGroup01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/view_left_margin"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/RadioButton01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/radio_value_oui" />
<RadioButton
android:id="#+id/RadioButton02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/radio_value_non" />
</RadioGroup>
</TableRow>
<TableRow
android:id="#+id/TableRow02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/row_margin_top" >
<TextView
android:id="#+id/TextView02"
android:layout_width="#dimen/label_width"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/view_left_margin"
android:text="#string/ecran3_85_limit_tonnage" />
<EditText
android:id="#+id/EditText01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/view_left_margin"
android:ems="#string/editTextEms"
android:inputType="numberDecimal" />
</TableRow>
<TableRow
android:id="#+id/TableRow03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/row_margin_top"
android:visibility="gone" >
<TextView
android:id="#+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/view_left_margin"
android:text="#string/ecran3_86_derog" />
</TableRow>
<TableRow
android:id="#+id/TableRow04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/row_margin_top" >
<TextView
android:id="#+id/TextView04"
android:layout_width="#dimen/label_width"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/view_left_margin"
android:text="#string/ecran3_87_limit_hauteur" />
<EditText
android:id="#+id/EditText03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/view_left_margin"
android:ems="#string/editTextEms"
android:inputType="numberDecimal" />
</TableRow>
<TableRow
android:id="#+id/TableRow05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/row_margin_top" >
<TextView
android:id="#+id/TextView05"
android:layout_width="#dimen/label_width"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/view_left_margin"
android:text="#string/ecran3_88_limit_largeur" />
<EditText
android:id="#+id/EditText04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/view_left_margin"
android:ems="#string/editTextEms"
android:inputType="numberDecimal" />
</TableRow>
<TableRow
android:id="#+id/TableRow06"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/row_margin_top" >
<TextView
android:id="#+id/TextView06"
android:layout_width="#dimen/label_width"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/view_left_margin"
android:text="#string/ecran3_89_trav_jour" />
<RadioGroup
android:id="#+id/RadioGroup06"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/view_left_margin"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/RadioButton11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/radio_value_oui" />
<RadioButton
android:id="#+id/RadioButton12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/radio_value_non" />
</RadioGroup>
</TableRow>
<TableRow
android:id="#+id/TableRow07"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/row_margin_top" >
<TextView
android:id="#+id/TextView07"
android:layout_width="#dimen/label_width"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/view_left_margin"
android:text="#string/ecran3_90_acces_intemperies" />
<RadioGroup
android:id="#+id/RadioGroup07"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/view_left_margin"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/RadioButton13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/radio_value_oui" />
<RadioButton
android:id="#+id/RadioButton14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/radio_value_non" />
</RadioGroup>
</TableRow>
<TableRow
android:id="#+id/TableRow08"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/row_margin_top" >
<TextView
android:id="#+id/TextView08"
android:layout_width="#dimen/label_width"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/view_left_margin"
android:text="#string/ecran3_91_acces_de_client" />
<RadioGroup
android:id="#+id/RadioGroup08"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/view_left_margin"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/RadioButton15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/radio_value_oui" />
<RadioButton
android:id="#+id/RadioButton16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/radio_value_non" />
</RadioGroup>
</TableRow>
<LinearLayout
android:id="#+id/LinearLayout02"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TableRow
android:id="#+id/TableRow09"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/row_margin_top" >
<TextView
android:id="#+id/TextView09"
android:layout_width="#dimen/label_width"
android:layout_height="fill_parent"
android:layout_marginLeft="#dimen/view_left_margin"
android:text="#string/ecran3_92_contraintes_reservoir" />
<EditText
android:id="#+id/EditText05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/view_left_margin"
android:ems="#string/editTextEms"
android:inputType="text" />
</TableRow>
<TableRow
android:id="#+id/TableRow10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/row_margin_top" >
<TextView
android:id="#+id/TextView10"
android:layout_width="#dimen/label_width"
android:layout_height="fill_parent"
android:layout_marginLeft="#dimen/view_left_margin"
android:text="#string/ecran3_93_dalle_pret" />
<RadioGroup
android:id="#+id/RadioGroup10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/view_left_margin"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/RadioButton19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/radio_value_oui" />
<RadioButton
android:id="#+id/RadioButton20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/radio_value_non" />
</RadioGroup>
</TableRow>
<!-- TableRow10 to TableRow26 -->
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
Without seeing your full layout I would say to replace that TableLayout with a ListView.
I'm guessing that you have a number of Views for each row, if you switch to a ListView you'll avoid the need to load the entire layout in memory, instead you'll load only the visible rows on the screen of the ListView + any views you have besides that.
With the above approach, you'll be able to remove a substantial number of rows from the current layout.
EDIT :
Based on your added layout, some advices:
TableRow can be used as a normal view in a layout but its main purpose it to be a child of a TableLayout.
If you don't want your Buttons from tableRow00 to have equal width then you can make a small improvement and instead of your current layout, replace LinearLayout00 with a RelativeLayout, remove the tableRow00 and then place the Buttons and the ScrollView using the rules of RelativeLayout.
Replace LinearLayout01 with a TableLayout.
I don't know why you added the LinearLayout02(I'm guessing all of your rows are the same?!) but you should remove it and directly append TableRow09 - TableRow26 to LinearLayout01.
The rest of my answer remains.