This is the XML file for the main fragment that i am currently dealing with. the problem i am having is that when i clean the project it does not give me any errors but when i run the program the emulator crashes.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.budgetfuel.MainActivity$PlaceholderFragment" >
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="20dp" >
<TextView
android:id="#+id/textView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Select Car:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="20dp" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Price Per Litre:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<EditText
android:id="#+id/editText1"
android:layout_width="171dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10" />
</LinearLayout>
<Space
android:id="#+id/Space1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical" />
<LinearLayout
android:id="#+id/LinearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="20dp" >
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.66"
android:text="Litres:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<EditText
android:id="#+id/editText2"
android:layout_width="171dp"
android:layout_height="wrap_content"
android:layout_weight="0.27"
android:ems="10" />
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="20dp" >
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="34dp"
android:layout_weight="0.80"
android:text="Odo Reading:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<EditText
android:id="#+id/editText3"
android:layout_width="186dp"
android:layout_height="wrap_content"
android:layout_weight="0.40"
android:ems="10" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayout5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="20dp" >
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.20"
android:text="Date:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<Button
android:id="#+id/buttonDateSet"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:text="Change Date:" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:id="#+id/LinearLayout6"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/Output"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</LinearLayout>
Related
android.view.InflateException: Binary XML file line #44: ScrollView can host only one direct childCaused by: java.lang.IllegalStateException: ScrollView can host only one direct child at android.widget.ScrollView.addView(ScrollView.java:279)
atretrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:70)
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:aapt="http://schemas.android.com/aapt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/half_view_margin_standard"
android:layout_marginTop="#dimen/view_margin_standard"
android:layout_marginRight="#dimen/half_view_margin_standard"
android:layout_marginBottom="#dimen/half_view_margin_standard">
<LinearLayout
android:orientation="vertical"
android:id="#+id/ll_home_header_parent"
android:background="#color/card_background_color"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.core.widget.NestedScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<TextView
android:textSize="#dimen/app_titles_text_size"
android:textStyle="bold"
android:textColor="#color/abc_decor_view_status_guard"
android:gravity="center"
android:layout_gravity="center"
android:id="#+id/tv_month_name"
android:paddingTop="#dimen/view_margin_standard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="மே - திங்கள்"/>
<LinearLayout android:gravity="center" android:layout_gravity="center" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="#dimen/half_view_margin_standard">
<TextView android:textSize="#dimen/app_display_type_1_text_size"
android:textColor="#color/abc_decor_view_status_guard"
android:gravity="center"
android:layout_gravity="center"
android:id="#+id/tv_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="08-05-2017"
android:fontFamily="#font/product_bold"/>
</LinearLayout>
<LinearLayout
android:layout_width="335dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="#dimen/half_view_margin_standard"
android:layout_marginBottom="#dimen/half_view_margin_standard"
android:orientation="horizontal">
<TextView
android:id="#+id/sf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/half_view_margin_standard"
android:gravity="left"
android:text="நல்ல நேரம்"
android:textColor="#color/black"
android:textSize="#dimen/app_body_type_1_text_size" />
<TextView
android:id="#+id/tv_morning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/half_view_margin_standard"
android:gravity="left"
android:text="கா"
android:textColor="#color/black"
android:textSize="#dimen/app_body_type_1_text_size" />
<TextView
android:id="#+id/tv_morning_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/half_view_margin_standard"
android:gravity="left"
android:text="10.30 - 12.00"
android:textColor="#color/black"
android:textSize="#dimen/app_body_type_1_text_size" />
<TextView
android:id="#+id/tv_evening"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/half_view_margin_standard"
android:text="மா"
android:textColor="#color/black"
android:textSize="#dimen/app_body_type_1_text_size" />
<TextView
android:id="#+id/tv_evening_time"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/half_view_margin_standard"
android:gravity="left"
android:text="10.30 - 12.00"
android:textColor="#color/black"
android:textSize="#dimen/app_body_type_1_text_size" />
</LinearLayout><![CDATA[ 7.00 Maalai 4.30 - 6.00"/>
]]>
<LinearLayout
android:orientation="vertical"
android:background="#color/card_background_color"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/tv_tamil_month_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/half_view_margin_standard"
android:gravity="center"
android:text="சித்திரைத்"
android:textColor="#color/abc_decor_view_status_guard"
android:textSize="#dimen/app_big_sub_heads_text_size" />
<TextView
android:id="#+id/tv_viratham_home"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/half_view_margin_standard"
android:gravity="center"
android:text="சித்திரைத்"
android:textColor="#color/abc_decor_view_status_guard"
android:textSize="#dimen/app_big_sub_heads_text_size" />
<TextView
android:id="#+id/tv_viratham_time_range"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_gravity="center"
android:layout_marginLeft="#dimen/half_view_margin_standard"
android:gravity="center"
android:text="சித்திரைத்"
android:textColor="#color/abc_decor_view_status_guard"
android:textSize="#dimen/app_big_sub_heads_text_size" />
<TextView
android:textSize="#dimen/app_body_type_1_text_size"
android:textColor="#color/black"
android:gravity="center"
android:layout_gravity="center"
android:id="#+id/tv_vishesham"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/half_view_margin_standard"
android:text="காலை"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
</androidx.cardview.widget.CardView>`
`
how to clear error this
you should use scrollview like this sample
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView />
<TextView />
<TextView />
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.core.widget.NestedScrollView>
Not Like this
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</androidx.appcompat.widget.LinearLayoutCompat>
<TextView />
<TextView />
<TextView />
</androidx.core.widget.NestedScrollView>
I have been getting the above error for quite some time. Upon a lot of prodding around, I've come to the conclusion that its my xml itself which is causing this issue. I have commented ALL of my code in my java file and tried to load JUST THE LAYOUT. Even then the warning keeps popping up. I am herein attaching my xml file, hoping someone can shed some light on this. I would like to know what are the "heavy duty" work being performed which is causing my app to "skip frames".
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:clipToPadding="false"
android:id="#+id/coordinator"
android:background="#drawable/back_1"
tools:context="com.avantaritech.flipa.MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/first_bar">
<android.support.v7.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_menu_white_24dp"
android:contentDescription="#string/overflow_home"
android:id="#+id/nav_button"/>
<android.support.v7.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/fill"
android:layout_alignParentTop="true"
android:id="#+id/logo"
android:layout_centerHorizontal="true" />
<android.support.v7.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/sync_green"
android:id="#+id/sync_button"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"/>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/_1sdp"
android:layout_margin="#dimen/_5sdp"
android:background="#android:color/darker_gray"
android:layout_below="#+id/logo"
android:id="#+id/view" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/view"
android:id="#+id/mega_relative"
android:layout_alignEnd="#+id/view">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/viewpager_holder_first"
android:layout_alignParentStart="true"
android:layout_marginTop="#dimen/_10sdp"
android:layout_alignParentTop="true">
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_marginTop="#dimen/_1sdp"
android:id="#+id/viewpager_first"
android:layout_height="#dimen/_225sdp"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true">
</android.support.v4.view.ViewPager>
<me.relex.circleindicator.CircleIndicator
android:id="#+id/indicator"
android:layout_width="match_parent"
android:layout_height="#dimen/_25sdp"
android:layout_below="#+id/viewpager_first"/>
</RelativeLayout>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="#dimen/_110sdp"
android:layout_below="#+id/viewpager_holder_first"
android:scrollbars="none"
android:overScrollMode="always"
android:id="#+id/horizontalScrollView">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/_10sdp"
>
<FrameLayout
android:layout_width="#dimen/_100sdp"
android:layout_height="match_parent"
android:background="#color/textbox_home">
<ImageView
android:layout_width="#dimen/_30sdp"
android:layout_height="#dimen/_30sdp"
android:src="#drawable/hr"
android:id="#+id/hr_image_home"
android:layout_margin="#dimen/_5sdp"
android:layout_gravity="left|top" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Heart Rate"
android:fontFamily="sans-serif-light"
android:id="#+id/hr_text_home"
android:layout_marginStart="#dimen/_10sdp"
android:layout_marginTop="#dimen/_10sdp"
android:layout_gravity="end|top" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00"
android:id="#+id/home_hr"
android:textSize="35sp"
android:textStyle="bold"
android:layout_gravity="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BPM"
android:textColor="#color/skin_v1"
android:layout_marginTop="#dimen/_75sdp"
android:layout_marginBottom="#dimen/_5sdp"
android:layout_gravity="center_horizontal|bottom" />
</FrameLayout>
<FrameLayout
android:layout_width="#dimen/_100sdp"
android:layout_height="match_parent"
android:elevation="#dimen/_10sdp"
android:layout_marginStart="#dimen/_15sdp"
android:background="#color/textbox_home">
<ImageView
android:layout_width="#dimen/_30sdp"
android:layout_height="#dimen/_30sdp"
android:src="#drawable/steps"
android:id="#+id/steps_image_home"
android:layout_margin="#dimen/_5sdp"
android:layout_gravity="left|top" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00"
android:id="#+id/home_steps"
android:textSize="30sp"
android:textStyle="bold"
android:layout_gravity="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="STEPS"
android:textColor="#color/skin_v1"
android:layout_marginTop="#dimen/_75sdp"
android:layout_marginBottom="#dimen/_5sdp"
android:layout_gravity="center_horizontal|bottom" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Steps"
android:fontFamily="sans-serif-light"
android:id="#+id/steps_text_home"
android:layout_marginEnd="#dimen/_5sdp"
android:layout_marginStart="#dimen/_30sdp"
android:layout_marginTop="#dimen/_10sdp"
android:layout_gravity="center_horizontal|top" />
</FrameLayout>
<FrameLayout
android:layout_width="#dimen/_100sdp"
android:layout_height="match_parent"
android:elevation="#dimen/_10sdp"
android:layout_marginStart="#dimen/_25sdp"
android:background="#color/textbox_home">
<ImageView
android:layout_width="#dimen/_30sdp"
android:layout_height="#dimen/_30sdp"
android:src="#drawable/dist"
android:id="#+id/dist_image_home"
android:layout_margin="#dimen/_5sdp"
android:layout_gravity="left|top" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00"
android:id="#+id/dist_textview_home"
android:textSize="30sp"
android:textStyle="bold"
android:layout_gravity="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="METERS"
android:id="#+id/dist_unit"
android:textColor="#color/skin_v1"
android:layout_marginTop="#dimen/_75sdp"
android:layout_marginBottom="#dimen/_5sdp"
android:layout_gravity="center_horizontal|bottom" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Distance"
android:fontFamily="sans-serif-light"
android:id="#+id/dist_text_home"
android:layout_marginTop="#dimen/_10sdp"
android:layout_marginStart="#dimen/_15sdp"
android:layout_gravity="center_horizontal|top" />
</FrameLayout>
<FrameLayout
android:layout_width="#dimen/_100sdp"
android:layout_height="match_parent"
android:elevation="#dimen/_10sdp"
android:layout_marginStart="#dimen/_30sdp"
android:background="#color/textbox_home">
<ImageView
android:layout_width="#dimen/_30sdp"
android:layout_height="#dimen/_30sdp"
android:src="#drawable/pace"
android:id="#+id/pace_image_home"
android:layout_margin="#dimen/_5sdp"
android:layout_gravity="left|top" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00"
android:id="#+id/pace_textview_home"
android:textSize="30sp"
android:textStyle="bold"
android:layout_gravity="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="STEPS/MIN"
android:textColor="#color/skin_v1"
android:layout_marginTop="#dimen/_75sdp"
android:layout_marginBottom="#dimen/_5sdp"
android:layout_gravity="center_horizontal|bottom" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Avg. Pace"
android:fontFamily="sans-serif-light"
android:id="#+id/pace_text_home"
android:layout_marginTop="#dimen/_10sdp"
android:layout_marginStart="#dimen/_10sdp"
android:layout_gravity="center_horizontal|top" />
</FrameLayout>
<FrameLayout
android:layout_width="#dimen/_100sdp"
android:layout_height="match_parent"
android:elevation="#dimen/_10sdp"
android:layout_marginStart="#dimen/_30sdp"
android:background="#color/textbox_home">
<ImageView
android:layout_width="#dimen/_20sdp"
android:layout_height="#dimen/_20sdp"
android:src="#drawable/cal"
android:id="#+id/cal_avg_image_home"
android:layout_margin="#dimen/_5sdp"
android:layout_gravity="left|top" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00"
android:id="#+id/cal_avg_textview_home"
android:textSize="30sp"
android:textStyle="bold"
android:layout_gravity="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="KCAL/MIN"
android:textColor="#color/skin_v1"
android:layout_marginTop="#dimen/_75sdp"
android:layout_marginBottom="#dimen/_5sdp"
android:layout_gravity="center_horizontal|bottom" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Avg. KCAL"
android:fontFamily="sans-serif-light"
android:id="#+id/kcal_text_home"
android:layout_marginTop="#dimen/_10sdp"
android:layout_marginStart="#dimen/_10sdp"
android:layout_gravity="center_horizontal|top" />
</FrameLayout>
</LinearLayout>
</HorizontalScrollView>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#+id/mega_relative"
android:layout_toEndOf="#+id/nav_button"
android:layout_alignParentStart="true">
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
app:fabSize="normal"
android:id="#+id/workout_start"
android:src="#drawable/run"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
I parsed the site and now trying to put the data into TableLayout. But I cannot properly build the table. In portrait orientation the result is aceptable, in landscape something terrible. Instead of 8 columns on screen it only shows 3.
It's what I want to achive - Schedule Online
A part of my activity_main.xml for landscape orientation.
Could you give me an advice of what shall I do to get proper schedule grid?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="sm.play.sportlife.ua.MainActivity"
tools:ignore="MergeRootFrame" >
<TableLayout
android:id="#+id/tableLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="1, 2, 3, 4, 5, 6, 7" >
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/shape_rec" >
<TextView
android:id="#+id/textView0"
android:layout_width="70dp"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:text="Time"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:gravity="center_horizontal"
android:text="Monday"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:gravity="center_horizontal"
android:text="Tuesday"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:gravity="center_horizontal"
android:text="Wednesday"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:gravity="center_horizontal"
android:text="Thursday"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:gravity="center_horizontal"
android:text="Friday"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:gravity="center_horizontal"
android:text="Saturday"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:gravity="center_horizontal"
android:text="Sunday"
android:textAppearance="?android:attr/textAppearanceSmall" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/shape_rec" >
<TextView
android:id="#+id/textViewDate0"
android:layout_width="70dp"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/textViewDate1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:gravity="center_horizontal" />
<TextView
android:id="#+id/textViewDate2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:gravity="center_horizontal" />
<TextView
android:id="#+id/textViewDate3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:gravity="center_horizontal" />
<TextView
android:id="#+id/textViewDate4"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:gravity="center_horizontal" />
<TextView
android:id="#+id/textViewDate5"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:gravity="center_horizontal" />
<TextView
android:id="#+id/textViewDate6"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:gravity="center_horizontal" />
<TextView
android:id="#+id/textViewDate7"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:gravity="center_horizontal" />
</TableRow>
</TableLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/tableLayout" >
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="1, 2, 3, 4, 5, 6, 7" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/shape_rec" >
<TextView
android:id="#+id/R1C1"
android:layout_width="70dp"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|center_vertical" />
<TextView
android:id="#+id/R1C2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/R1C3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/R1C4"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/R1C5"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/R1C6"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/R1C7"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/R1C8"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/shape_rec" >
<TextView
android:id="#+id/R2C1"
android:layout_width="70dp"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|center_vertical" />
<TextView
android:id="#+id/R2C2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/R2C3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/R2C4"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/R2C5"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/R2C6"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/R2C7"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/R2C8"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/shape_rec" >
<TextView
android:id="#+id/R3C1"
android:layout_width="70dp"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|center_vertical" />
<TextView
android:id="#+id/R3C2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/R3C3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/R3C4"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/R3C5"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/R3C6"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/R3C7"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/R3C8"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#drawable/shape_rec"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
</TableRow>
</TableLayout>
</ScrollView>
</RelativeLayout>
Thanks in advance!!
Please have a look at the following code
input.xml
<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"
android:background="#drawable/background_main" >
<ImageView
android:id="#+id/logo_image"
android:background="#drawable/background_green"
android:src="#drawable/titleimage"
android:layout_width="match_parent"
android:layout_height="50dp"
/>
<ScrollView
android:id="#+id/scroller"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/logo_image"
android:layout_marginTop="10dp"
>
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="*" >
<TableRow
android:id="#+id/device_type_row"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:layout_marginRight="5dp" >
<RadioButton
android:id="#+id/device_type_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_weight="2"
android:text="#string/device_type" />
<RadioGroup
android:id="#+id/device_type_radio_selection"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<RadioButton
android:id="#+id/radioIos"
android:layout_width="wrap_content"
android:layout_height = "wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/iOS"
/>
<RadioButton
android:id="#+id/radioAndroid"
android:layout_width="wrap_content"
android:layout_height = "wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/android"
/>
</RadioGroup>
</TableRow>
<TableRow
android:id="#+id/days_as_customers_row"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:layout_marginRight="5dp" >
<RadioButton
android:id="#+id/days_as_customers_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/days_as_customers" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="2" >
<SeekBar
android:id="#+id/days_as_customer_seekbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="#+id/days_as_customer_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1/210"
android:layout_weight="1"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</TableRow>
</TableLayout>
</ScrollView>
<Button
android:id="#+id/input_submit_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#drawable/submit_button_img" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="#drawable/logo"/>
</RelativeLayout>
Basically, this gives the following UI
Now the problem is, the RadioButtons with text in the first column of the table takes only 40% of the available width. But, I need them to take 75% of the available width, and the things in second column can get the rest.
How can I do this?
Try this..
<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"
android:background="#drawable/background_main" >
<ImageView
android:id="#+id/logo_image"
android:background="#drawable/background_green"
android:src="#drawable/titleimage"
android:layout_width="match_parent"
android:layout_height="50dp"
/>
<ScrollView
android:id="#+id/scroller"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/logo_image"
android:layout_marginTop="10dp"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:id="#+id/device_type_row"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:layout_marginRight="5dp" >
<RadioButton
android:id="#+id/device_type_radio"
android:layout_width="0dp"
android:layout_weight="0.75"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/device_type" />
<RadioGroup
android:id="#+id/device_type_radio_selection"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:orientation="horizontal">
<RadioButton
android:id="#+id/radioIos"
android:layout_width="wrap_content"
android:layout_height = "wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/iOS"
/>
<RadioButton
android:id="#+id/radioAndroid"
android:layout_width="wrap_content"
android:layout_height = "wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/android"
/>
</RadioGroup>
</LinearLayout>
<LinearLayout
android:id="#+id/days_as_customers_row"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:layout_marginRight="5dp" >
<RadioButton
android:id="#+id/days_as_customers_radio"
android:layout_width="0dp"
android:layout_weight="0.75"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/days_as_customers" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25">
<SeekBar
android:id="#+id/days_as_customer_seekbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="#+id/days_as_customer_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1/210"
android:layout_weight="1"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<Button
android:id="#+id/input_submit_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#drawable/submit_button_img" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="#drawable/logo"/>
</RelativeLayout>
Please have a look at the following code
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".HomeScreen" >
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="*"
android:layout_margin="10dp"
android:layout_centerInParent="true"
android:weightSum="4" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".3"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/fStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".3"
android:gravity="center"
android:clickable="true"
android:background="#android:drawable/btn_default"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/rStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".3"
android:gravity="center"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/sStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".3"
android:gravity="center"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/cStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".3"
android:gravity="center"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/aStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".3"
android:gravity="center"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/lStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".3"
android:gravity="center"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/oStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".3"
android:gravity="center"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".3"
android:gravity="center"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/eStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".3"
android:gravity="center"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".3"
android:gravity="center"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/dStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".3"
android:gravity="center"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/aStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</TableRow>
</TableLayout>
</RelativeLayout>
In WVGA 5.1 Screen, this generates the following UI
As you can see, there is a massive gap between rows. I want to avoid this, so it will look good in all smartphones. How can I do this?
Make height & width of tableRow as fill_parent and height of every LinearLayout also as fill_parent
Use this data
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".HomeScreen" >
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="*"
android:layout_margin="10dp"
android:layout_centerInParent="true"
android:weightSum="4" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".3"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:gravity="center"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/fStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".3"
android:gravity="center"
android:clickable="true"
android:background="#android:drawable/btn_default"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/rStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".3"
android:gravity="center"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/sStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".3"
android:gravity="center"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/cStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".3"
android:gravity="center"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/aStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".3"
android:gravity="center"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/lStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".3"
android:gravity="center"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/oStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".3"
android:gravity="center"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".3"
android:gravity="center"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/eStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</TableRow>
<TableRow
android:id="#+id/tableRow4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".3"
android:gravity="center"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".3"
android:gravity="center"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/dStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight=".3"
android:gravity="center"
android:background="#android:drawable/btn_default"
android:clickable="true"
android:orientation="vertical" >
<ImageView
android:id="#+id/imageView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/aStr"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</TableRow>
</TableLayout>
</RelativeLayout>
Table row's height could be match_parent and width could be 0dip.
Try setting android:layout_margin to abit less and let me know if it solves the problem.
It's because your using linear layout in vertical and applying weight of 3
In your TableLayout Set the height to wrap_content and your space will be removed.
android:layout_height="wrap_content"
Also to get the best result of the android:weight property set the each layout's width to 0dp wherever you have assigned a weight.