Android: Image button is not alligned to right - android

I want my image button to be placed on the rt side bottom of the scree. but it is not getting visible.Please see the code.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date of Birth:" />
<Button
android:id="#+id/dateButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:text="Select date" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Manual labour" />
<EditText
android:id="#+id/ed1"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:inputType="number" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gender :" />
<RadioGroup
android:id="#+id/radioSex"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="#+id/radioMale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Male" />
<RadioButton
android:id="#+id/radioFemale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female" />
</RadioGroup>
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Occupation" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="#array/occuaption_arrays"
android:prompt="#string/occupation_prompt" />
</TableRow>
<TableRow
android:id="#+id/tableRow5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Monthly Income" />
<Spinner
android:id="#+id/spinner2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="#array/income_arrays"
android:prompt="#string/income_prompt" />
</TableRow>
</TableLayout>
<ImageButton
android:id="#+id/next"
android:layout_height="50dp"
android:layout_width="50dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:contentDescription="dfg"
android:src="#drawable/next"
android:visibility="visible"/>
I have tried using RelativeLayout as parent and add attribute android:layout_alignParentRight="true" and android:layout_alignParentBottom="true"
My image is very large.Is that can be a problem?

You have setted match-parent to width and height of TableLayout. So TableLayout overlaps ImageButton
use below code...
android:layout_width="match_parent"
android:layout_height="wrap-content"

Related

android design xml layout alignment (how to draw the like that)

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.

Android: Textview out of boundary

I have been trying to make this Layout which contains a Textview in a TableLayout. The textview however doesn't fit inside the layout. It goes out of the boundary. Changing the width to fill_parent or wrap_content doesn't seem to fix it.
Please see this screenshot
The following is the xml code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ReportDetailActivity" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:src="#drawable/camera_icon" />
<TextView
android:id="#+id/textViewCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:gravity="center"
android:text="Pothole"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TableRow
android:id="#+id/tableRow1"
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="Comment : "
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textViewComment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Location : "
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textViewLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="aaaaaadsk jfshdfhsdkh fdsfdshfkdshfk hsdkhfk sdhkfhsd;kfhs"
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date : "
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textViewDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
</TableLayout>
Try add the layout_weight;
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Location : "
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textViewLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="aaaaaadsk jfshdfhsdkh fdsfdshfkdshfk hsdkhfk sdhkfhsd;kfhs"
android:textAppearance="?android:attr/textAppearanceLarge" />
Try giving fix width to the textview. This will prevent from text going off the screen:
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Location : "
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textViewLocation"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="aaaaaadsk jfshdfhsdkh fdsfdshfkdshfk hsdkhfk sdhkfhsd;kfhs"
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
Use this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ReportDetailActivity" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="centerInside"
android:src="#drawable/camera_icon" />
<TextView
android:id="#+id/textViewCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:gravity="center"
android:text="Pothole"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="#+id/tableRow1"
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="Comment : "
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textViewComment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Location : "
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textViewLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="aaaaaadsk jfshdfhsdkh fdsfdshfkdshfk hsdkhfk sdhkfhsd;kfhs"
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date : "
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textViewDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
</TableLayout>
</LinearLayout>
try to set fix layout_width to your textview and set maxlines or minlines attribute if needed.

Android Horizontal Scroll View

i have a layout having many fields and i wish to add scrollbars for both horizontal and vertical layout.But vertical scroll is working horizontal scroll is not working.I have loaded the text fields dynamically in program and add the fields with web service .
My Activity
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LayoutScroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="horizontal|vertical" >
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="10dp"
android:layout_marginTop="30dp"
android:gravity="fill|fill_horizontal"
android:orientation="vertical" >
<TableRow
android:id="#+id/Row_User_Deletion"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#DF0101"
android:gravity="center" >
<TextView
android:id="#+id/user_creation_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/txt_delete_user_userDeletion"
android:textColor="#color/white"
android:textSize="15dp" />
</TableRow>
<TableRow
android:id="#+id/RowUserType"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="10dp" >
<TextView
android:id="#+id/txt_delete_user_selectuserType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="#string/txt_delete_user_selectuserType"
android:textColor="#424242" />
<Spinner
android:id="#+id/spin_delete_userType"
android:layout_width="120dp"
android:layout_height="50dp"
android:layout_marginBottom="5dp"
android:entries="#array/utype" />
<Button
android:id="#+id/btn_spinner_user_search_select"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginTop="5dp"
android:background="#drawable/redbtn"
android:text="#string/btn_delete_user_search_user" />
</TableRow>
<TableRow
android:id="#+id/deleteUserRow"
android:layout_width="match_parent"
android:layout_height="34dp"
android:layout_marginTop="10dp"
android:gravity="fill" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/txt_user_creation_userId"
android:textColor="#424242" />
<EditText
android:id="#+id/txt_user_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button1"
android:layout_width="55dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:background="#drawable/redbtn"
android:text="#string/btn_delete_user_search_user" />
</TableRow>
<TableLayout
android:id="#+id/delete_userDetails_Table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:stretchColumns="*" >
<TableRow
android:id="#+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:background="#color/red" >
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_delete_user_select"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView3"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_user_creation_userId"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView4"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_user_creation_userName"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView5"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_delete_user_UserRole"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/txt_componentmaster_createdDate"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/txt_componentmaster_createdBy"
android:textColor="#color/white" />
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
ImageView
Please keep in mind that the view that you want to scroll Horizontal is must have LinearLayout as parent then only you can set the HorizontalScrollView between that layout.
And Put one HorizontalScrollView as the Parent of those both LinearLayout.
Hope this will help you.
Smple:
<HORIZONTAL_VIEW ... >
<!-- Your First Layout -->
<LinearLayout ... >
</LinearLayout>
<!-- Your Second Layout -->
<LinearLayout ... >
</LinearLayout>
</HORIZONTAL_VIEW ... >
Hope you got my point.
Feel free for any query. :)
Try the Scroll Bars with out the Scrollview..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="10dp"
android:layout_marginTop="30dp"
android:gravity="fill|fill_horizontal"
android:scrollbars="horizontal|vertical"
android:orientation="vertical" >
<TableRow
android:id="#+id/Row_User_Deletion"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#DF0101"
android:gravity="center" >
<TextView
android:id="#+id/user_creation_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/txt_delete_user_userDeletion"
android:textColor="#color/white"
android:textSize="15dp" />
</TableRow>
<TableRow
android:id="#+id/RowUserType"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="10dp" >
<TextView
android:id="#+id/txt_delete_user_selectuserType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="#string/txt_delete_user_selectuserType"
android:textColor="#424242" />
<Spinner
android:id="#+id/spin_delete_userType"
android:layout_width="120dp"
android:layout_height="50dp"
android:layout_marginBottom="5dp"
android:entries="#array/utype" />
<Button
android:id="#+id/btn_spinner_user_search_select"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginTop="5dp"
android:background="#drawable/redbtn"
android:text="#string/btn_delete_user_search_user" />
</TableRow>
<TableRow
android:id="#+id/deleteUserRow"
android:layout_width="match_parent"
android:layout_height="34dp"
android:layout_marginTop="10dp"
android:gravity="fill" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/txt_user_creation_userId"
android:textColor="#424242" />
<EditText
android:id="#+id/txt_user_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:ems="10" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button1"
android:layout_width="55dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:background="#drawable/redbtn"
android:text="#string/btn_delete_user_search_user" />
</TableRow>
<TableLayout
android:id="#+id/delete_userDetails_Table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical"
android:stretchColumns="*" >
<TableRow
android:id="#+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:background="#color/red" >
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_delete_user_select"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView3"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_user_creation_userId"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView4"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_user_creation_userName"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView5"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="#string/txt_delete_user_UserRole"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/txt_componentmaster_createdDate"
android:textColor="#color/white" />
<TextView
android:id="#+id/textView5"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/txt_componentmaster_createdBy"
android:textColor="#color/white" />
</TableRow>
</TableLayout>
</LinearLayout>

Android TableLayout wrap content

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

TableLayout placing

How to place TableLayout a grid of buttons 5 on 5 on the screen center?
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/Table5"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="30dp"
android:weightSum="5"/>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableLayout
android:id="#+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"
android:layout_margin="10dp"
android:background="#ffffff"
android:gravity="center" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b11" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b12" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b13" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b14" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b15" />
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b21" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b22" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b23" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b24" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b25" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b31" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="b32" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b33" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b34" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b35" />
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b41" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b42" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b43" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b44" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b45" />
</TableRow>
<TableRow
android:id="#+id/tableRow5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b51" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b52" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b53" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b54" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="b55" />
</TableRow>
</TableLayout>
</RelativeLayout>
Use the above code in an android layout XML file to create your 5x5 button matrix using a TableLayout
<GridView
android:id="#+id/myGrid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:columnWidth="#dimen/grid_width"
android:gravity="center"
android:numColumns="auto_fit"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:stretchMode="spacingWidth"
android:verticalSpacing="8dp" />
and into grid_width, you can set a dimension (for hdpi, 480/5).
I don't know if this work for your situation. But try it
Try adding android:layout_gravity="center" attribute to the TableLayout
(If that doesn't work, wrap the TableLayout with a LinearLayout or something like that.)

Categories

Resources