How to disable Overlay in RelativeLayout? - java

If I write a text in one of the two fields, the last textViews are displayed over the button...
Thats bad.
I don't want it.
I'm searching for an prosibilty to disable that.
Maybe for example to hide the button if the keyboard is displayed
or make the text scrollable
donst worry abaut the grid, it gets in 9 rows TextViews
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/RelativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/padding_small"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
tools:context=".ActivityMain_plain" >
<Button
android:id="#+id/Button_berechnen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:paddingBottom="#dimen/padding_small"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:text="#string/Button_berechnen" />
<EditText
android:id="#+id/input_ipAdresse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/Button_berechnen"
android:layout_toRightOf="#+id/tV_input_snm_txt"
android:ems="10"
android:gravity="right"
android:inputType="phone"
android:paddingRight="#dimen/padding_small"
android:textSize="#dimen/fontsize_medium" >
<requestFocus android:layout_width="match_parent" />
</EditText>
<EditText
android:id="#+id/input_snm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/input_ipAdresse"
android:layout_alignParentRight="true"
android:layout_below="#+id/input_ipAdresse"
android:ems="10"
android:gravity="right"
android:inputType="phone"
android:paddingRight="#dimen/padding_small"
android:textSize="#dimen/fontsize_medium" />
<TextView
android:id="#+id/tV_input_snm_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/input_snm"
android:layout_alignParentLeft="true"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:paddingTop="#dimen/padding_small"
android:text="#string/input_snm"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/tV_input_ipAdresse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/input_ipAdresse"
android:layout_alignParentLeft="true"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:paddingTop="#dimen/padding_small"
android:text="#string/input_ipAdresse"
android:textAppearance="?android:attr/textAppearanceMedium" />
<GridLayout
android:id="#+id/table_gridLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/input_snm"
android:columnCount="5"
android:fadingEdge="horizontal|vertical"
android:paddingBottom="#dimen/padding_small"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:paddingTop="#dimen/padding_medium"
android:scrollbars="horizontal|vertical" >
</GridLayout>
<TextView
android:id="#+id/tV_Klasse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/table_gridLayout"
android:layout_marginTop="10dp"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:paddingTop="#dimen/padding_small"
android:text="#string/txt_Klasse" />
<TextView
android:id="#+id/tV_BitsNetz"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/tV_Klasse"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:text="#string/txt_BitsNetz" />
<TextView
android:id="#+id/tV_BitsSubnetz"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/tV_BitsNetz_erg"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:text="#string/txt_BitsSubnetz" />
<TextView
android:id="#+id/tV_BitsHost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/tV_BitsSubnetz"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:text="#string/txt_BitsHost" />
<TextView
android:id="#+id/tV_MagischeZahl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/tV_BitsHost"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:text="#string/txt_MagischeZahl" />
<TextView
android:id="#+id/tV_AnzahlHost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/tV_AnzahlSubnetz"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:text="#string/txt_AnzHosts" />
<TextView
android:id="#+id/tV_AnzahlSubnetz"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/tV_MagischeZahl"
android:layout_below="#+id/tV_MagischeZahl"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:paddingTop="#dimen/padding_small"
android:text="#string/txt_AnzSubnetze" />
<TextView
android:id="#+id/tV_Klasse_erg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/tV_Klasse"
android:layout_alignBottom="#+id/tV_Klasse"
android:layout_alignRight="#+id/input_snm"
android:minWidth="100dp" />
<TextView
android:id="#+id/tV_BitsNetz_erg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/tV_BitsNetz"
android:layout_alignBottom="#+id/tV_BitsNetz"
android:layout_alignLeft="#+id/tV_Klasse_erg"
android:minWidth="100dp" />
<TextView
android:id="#+id/tV_BitsSubnetz_erg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/tV_BitsSubnetz"
android:layout_alignLeft="#+id/tV_Klasse_erg"
android:minWidth="100dp" />
<TextView
android:id="#+id/tV_BitsHost_erg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/tV_BitsHost"
android:layout_alignBottom="#+id/tV_BitsHost"
android:layout_alignLeft="#+id/tV_BitsNetz_erg"
android:minWidth="100dp" />
<TextView
android:id="#+id/tV_MagischeZahl_erg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/tV_MagischeZahl"
android:layout_alignBottom="#+id/tV_MagischeZahl"
android:layout_alignLeft="#+id/tV_BitsHost_erg"
android:minWidth="100dp" />
<TextView
android:id="#+id/tV_AnzahlSubnetz_erg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/tV_AnzahlSubnetz"
android:layout_alignLeft="#+id/tV_BitsHost_erg"
android:minWidth="100dp" />
<TextView
android:id="#+id/tV_AnzahlHost_erg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/tV_AnzahlHost"
android:layout_alignLeft="#+id/tV_MagischeZahl_erg"
android:minWidth="100dp" />
</RelativeLayout>
I know why, but no good way how to fix it...
I know with relative layouts overlays are possible, but here I don't want it...

If I understand correctly, this might solve your problem:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/RelativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/padding_small"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
tools:context=".ActivityMain_plain">
<Button
android:id="#+id/Button_berechnen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:paddingBottom="#dimen/padding_small"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:text="#string/Button_berechnen"/>
<EditText
android:id="#+id/input_ipAdresse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignRight="#+id/Button_berechnen"
android:layout_toRightOf="#+id/tV_input_snm_txt"
android:ems="10"
android:gravity="right"
android:inputType="phone"
android:paddingRight="#dimen/padding_small"
android:textSize="#dimen/fontsize_medium">
<requestFocus android:layout_width="match_parent"/>
</EditText>
<EditText
android:id="#+id/input_snm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/input_ipAdresse"
android:layout_alignParentRight="true"
android:layout_below="#+id/input_ipAdresse"
android:ems="10"
android:gravity="right"
android:inputType="phone"
android:paddingRight="#dimen/padding_small"
android:textSize="#dimen/fontsize_medium"/>
<TextView
android:id="#+id/tV_input_snm_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/input_snm"
android:layout_alignParentLeft="true"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:paddingTop="#dimen/padding_small"
android:text="#string/input_snm"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<TextView
android:id="#+id/tV_input_ipAdresse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/input_ipAdresse"
android:layout_alignParentLeft="true"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:paddingTop="#dimen/padding_small"
android:text="#string/input_ipAdresse"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<ScrollView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/Button_berechnen"
android:layout_below="#+id/input_snm">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<GridLayout
android:id="#+id/table_gridLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:columnCount="5"
android:fadingEdge="horizontal|vertical"
android:paddingBottom="#dimen/padding_small"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:paddingTop="#dimen/padding_medium"
android:scrollbars="horizontal|vertical">
</GridLayout>
<TextView
android:id="#+id/tV_Klasse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:paddingTop="#dimen/padding_small"
android:text="#string/txt_Klasse"/>
<TextView
android:id="#+id/tV_BitsNetz"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:text="#string/txt_BitsNetz"/>
<TextView
android:id="#+id/tV_BitsSubnetz"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:text="#string/txt_BitsSubnetz"/>
<TextView
android:id="#+id/tV_BitsHost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:text="#string/txt_BitsHost"/>
<TextView
android:id="#+id/tV_MagischeZahl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:text="#string/txt_MagischeZahl"/>
<TextView
android:id="#+id/tV_AnzahlHost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:text="#string/txt_AnzHosts"/>
<TextView
android:id="#+id/tV_AnzahlSubnetz"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/padding_small"
android:paddingRight="#dimen/padding_small"
android:paddingTop="#dimen/padding_small"
android:text="#string/txt_AnzSubnetze"/>
<TextView
android:id="#+id/tV_Klasse_erg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="100dp"/>
<TextView
android:id="#+id/tV_BitsNetz_erg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="100dp"/>
<TextView
android:id="#+id/tV_BitsSubnetz_erg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="100dp"/>
<TextView
android:id="#+id/tV_BitsHost_erg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="100dp"/>
<TextView
android:id="#+id/tV_MagischeZahl_erg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="100dp"/>
<TextView
android:id="#+id/tV_AnzahlSubnetz_erg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="100dp"/>
<TextView
android:id="#+id/tV_AnzahlHost_erg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="100dp"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
I haven't actually tested the code, but the notion should be correct.
Also, I would strongly suggest you revisit your XML layout, as it could be improved.

Related

How to create Sticky Header in a ScrollingActivity

I used ScrollActivity that comes in android studio to create a cool animation while scrolling. The ScrollActivity came with two xml files which are content_scrolling.xml and activity_scrolling.xml. I would like to create sticky headers inside the content_scrolling.xml. I created sticky headers before but the problem I am having is that the header does not "stick" right under the image where I'd like it to instead it sticks on top of the screen which is blocked by the image. I have provided an image of what I am trying to accomplish and I hope it helps understand what I am trying to do. Thank you!
activity_scrolling.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.myapplication.foodapp.ScrollingActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="#style/AppTheme.PopupOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="#+id/imageView2"
android:layout_width="match_parent"
android:layout_height="545dp"
android:layout_alignParentTop="true"
android:scaleType="fitXY"
android:src="#mipmap/food1"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Chipotle Chicken Fajitas"
android:textSize="27sp"
android:layout_gravity="bottom"
android:layout_marginBottom="40dp"
android:layout_marginLeft="5dp"
android:textColor="#fff"
android:id="#+id/first_food_title"/>
<me.grantland.widget.AutofitTextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="16 ingredients | 284 Calories | 1 hour"
android:singleLine="true"
android:textAlignment="center"
android:textColor="#fff"
android:layout_gravity="bottom"
android:textSize="20sp"
android:id="#+id/spec_text"/>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="200dp"
app:layout_collapseMode="pin"
/>
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:src="#mipmap/arrow"
android:id="#id/back_Arrow"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
content_scrolling.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
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"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.myapplication.foodapp.ScrollingActivity"
android:id="#+id/nested_scroll_view">
<RelativeLayout
android:id="#+id/relative_layout1"
android:layout_width="match_parent"
android:layout_height="2000dp"
android:background="#fff">
<me.grantland.widget.AutofitTextView
android:id="#+id/spec_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="16 ingredients | 284 Calories | 1 hour"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="20sp"
android:layout_alignBottom="#+id/imageView2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
app:sizeToFit="true"/>
<View
android:layout_width="wrap_content"
android:layout_height="55dp"
android:background="#2C7873"
android:layout_below="#+id/imageView2"
android:layout_alignRight="#+id/imageView3"
android:layout_alignEnd="#+id/imageView3"
android:id="#+id/ingredient_view"
/>
<ImageView
android:layout_width="70dp"
android:layout_height="50dp"
android:id="#+id/imageView3"
android:src="#drawable/servings"
android:layout_alignBottom="#+id/relativeLayout"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Ingredients"
android:textColor="#fff"
android:textSize="24sp"
android:textStyle="bold"
android:paddingLeft="5dp"
android:paddingTop="15dp"
android:layout_below="#+id/imageView2"
android:layout_alignRight="#+id/imageView3"
android:layout_alignEnd="#+id/imageView3"
/>
<TextView
android:id="#+id/bullet_one"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingTop="5px"
android:text="#string/_1_lb_boneless_skinless_chicken_breasts_cut_into_thin_strips"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_below="#+id/imageView3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:id="#+id/bullet_two"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/bullet_one"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:text="#string/_1_tsp_ground_cumin"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/bullet_three"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/bullet_two"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:text="#string/_1_tsp_chili_powder"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/bullet_four"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/bullet_three"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:text="#string/kosher_salt"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/bullet_five"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/bullet_four"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:text="#string/freshly_ground_black_pepper"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/bullet_six"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/bullet_five"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:text="#string/_1_tbsp_canola_oil"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/bullet_seven"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/bullet_six"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:text="#string/_1_red_bell_pepper_sliced"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/bullet_eight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/bullet_seven"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:text="#string/_1_small_onion_sliced"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/bullet_nine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/bullet_eight"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:text="#string/_1_c_sliced_mushrooms"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/bullet_ten"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/bullet_nine"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:text="#string/_3_garlic_cloves_chopped"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/bullet_elven"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/bullet_ten"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:text="#string/_1_tbsp_chopped_chipotles_in_adobo"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/bullet_twelve"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/bullet_ten"
android:layout_marginTop="29dp"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:text="#string/_1_1_2_tbsp_fresh_lime_juice"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/bullet_thirteen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/bullet_twelve"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:text="#string/_8_warm_flour_tortillas"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/bullet_fithteen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/bullet_thirteen"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:text="#string/cilantro_for_serving"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/bullet_sixteen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/bullet_fithteen"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:text="#string/lime_wedges_for_serving"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/bullet_fourteen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/bullet_sixteen"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:text="#string/grated_cheddar_cheese_for_serving"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textView23"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingTop="10dp"
android:text="View Directions"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="15sp"
android:layout_below="#+id/bullet_fourteen"
/>
<View
android:layout_width="wrap_content"
android:layout_height="55dp"
android:background="#2C7873"
android:layout_below="#+id/textView23"
android:layout_alignRight="#+id/imageView3"
android:layout_alignEnd="#+id/imageView3"
android:id="#+id/view2"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:tag="sticky"/>
<TextView
android:id="#+id/textView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingTop="10dp"
android:text="Nutrition Facts"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="24sp"
android:textStyle="bold"
android:layout_alignTop="#+id/view2"
android:layout_alignLeft="#+id/textView23"
android:layout_alignStart="#+id/textView23" />
<TextView
android:id="#+id/textView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text="View More"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="15sp"
android:layout_alignBottom="#+id/textView15"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="5dp"
android:layout_marginRight="5dp" />
<RelativeLayout
android:id="#+id/relativeLayout4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:paddingEnd="15dp"
android:paddingStart="30dp"
android:layout_below="#+id/view2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<ImageView
android:id="#+id/imageView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/protein" />
<ImageView
android:id="#+id/imageView19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="#+id/imageView18"
android:layout_toRightOf="#+id/imageView18"
android:src="#drawable/sodium" />
<ImageView
android:id="#+id/imageView20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="#+id/imageView19"
android:layout_toRightOf="#+id/imageView19"
android:src="#drawable/fats" />
<ImageView
android:id="#+id/imageView21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toEndOf="#+id/imageView20"
android:layout_toRightOf="#+id/imageView20"
android:src="#drawable/sugars" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#2C7873"
android:layout_below="#+id/relativeLayout4"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:id="#+id/view3"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:tag="sticky"/>
<TextView
android:id="#+id/textView19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:text="Reviews"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#fff"
android:textSize="24sp"
android:textStyle="bold"
android:layout_alignBottom="#+id/view3"
android:layout_alignLeft="#+id/textView15"
android:layout_alignStart="#+id/textView15" />
<RatingBar
android:id="#+id/ratingBar"
android:layout_width="230dp"
android:layout_height="35dp"
android:clickable="false"
android:numStars="5"
android:scaleX=".5"
android:scaleY=".5"
android:layout_alignTop="#+id/textView19"
android:layout_alignRight="#+id/textView16"
android:layout_alignEnd="#+id/textView16"
android:layout_marginTop="-5dp" />
<TextView
android:id="#+id/display_review"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#f1fcf0"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="20sp"
android:layout_below="#+id/view3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>

Android Studio. Align multiple text boxes under multiple check boxes and equal spacing to fit screen

This is what i am trying to achieve
But
this is what i get when uploaded on phone.
It seems ok in android studio fragment design preview but when uploaded on phone
checkboxes are not displayed :(.
Any better solutions?
Below is full xml code.
<?xml version="1.0" encoding="utf-8"?>
<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"
android:fitsSystemWindows="false"
tools:context=".MainFragment">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoText="false"
android:text="#string/getnotif"
android:layout_below="#+id/linearLayout5"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp" />
<CheckBox
android:id="#+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView"
android:layout_alignStart="#+id/textView"
android:layout_below="#+id/textView"
android:text="#string/mcall"
android:textSize="12sp" />
<CheckBox
android:id="#+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView"
android:layout_toEndOf="#+id/checkBox"
android:layout_toRightOf="#+id/checkBox"
android:text="#string/msms"
android:textSize="12sp" />
<Button
android:id="#+id/timePicker"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="00:00"
android:background="#3f51b5"
android:layout_alignTop="#+id/timePicker2"
android:layout_marginLeft="25dp"
android:layout_alignParentStart="true"
android:textColor="#ffffff" />
<Button
android:id="#+id/timePicker2"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="23:59"
android:background="#3f51b5"
android:layout_below="#+id/linearLayout4"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="false"
android:layout_alignParentEnd="false"
android:layout_marginRight="25dp"
android:layout_alignParentRight="true"
android:textColor="#ffffff" />
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/timePicker"
android:layout_marginTop="20dp"
android:orientation="horizontal"
android:layout_alignParentEnd="true">
<TextView
android:id="#+id/textView8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="0dp"
android:text="Days"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout"
android:orientation="horizontal"
android:layout_alignRight="#+id/linearLayout"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<CheckBox
android:id="#+id/checkBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
android:checked="false"
android:layout_weight="1"
android:text="#string/monday"
android:paddingLeft="-27dp"
android:paddingTop="40dp"
android:textSize="10dp" />
<CheckBox
android:id="#+id/checkBox4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
android:layout_weight="1"
android:text="#string/tuesday"
android:paddingLeft="-26dp"
android:paddingTop="40dp"
android:textSize="10dp" />
<CheckBox
android:id="#+id/checkBox5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
android:layout_weight="1"
android:text="#string/wednesday"
android:paddingLeft="-27dp"
android:paddingTop="40dp"
android:textSize="10dp" />
<CheckBox
android:id="#+id/checkBox6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
android:layout_weight="1"
android:text="#string/thursday"
android:paddingLeft="-27dp"
android:paddingTop="40dp"
android:textSize="10dp" />
<CheckBox
android:id="#+id/checkBox7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
android:layout_weight="1"
android:text="#string/friday"
android:paddingLeft="-24dp"
android:paddingTop="40dp"
android:textSize="10dp" />
<CheckBox
android:id="#+id/checkBox8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
android:checked="false"
android:layout_weight="1"
android:text="#string/saturday"
android:paddingLeft="-25dp"
android:paddingTop="40dp"
android:textSize="10dp" />
<CheckBox
android:id="#+id/checkBox9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false"
android:checked="false"
android:text="#string/sunday"
android:paddingLeft="-27dp"
android:paddingTop="40dp"
android:textSize="10dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
<Button
android:id="#+id/exitButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/button_state"
android:text="Exit"
android:layout_weight="0.5"
android:layout_marginRight="16dp"
android:textColor="#ffffff" />
<Button
android:id="#+id/saveButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/button_state"
android:text="Save"
android:layout_weight="0.5"
android:layout_marginLeft="16dp"
android:textColor="#ffffff" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="false"
android:layout_marginTop="20dp"
android:id="#+id/linearLayout4"
android:layout_alignParentEnd="false">
<TextView
android:id="#+id/textView7"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="#string/from"
android:layout_below="#+id/textView5"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="false"
android:gravity="center"
android:layout_marginTop="20dp"
android:layout_marginLeft="25dp" />
<TextView
android:id="#+id/textView23"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="0dp"
android:text="Time"
android:gravity="center"
android:layout_weight="1" />
<TextView
android:id="#+id/textView6"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="#string/to"
android:layout_below="#+id/textView5"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:gravity="center"
android:layout_marginTop="20dp"
android:layout_marginRight="25dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout5"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:layout_below="#+id/linearLayout2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
</LinearLayout>
</RelativeLayout>
Set all your checkboxes with layout_weight=1 inside a LinearLayout. Set the Linear Layout's orientation to vertical.
<?xml version="1.0" encoding="utf-8"?>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mon"
android:layout_weight="1"
android:id="#+id/checkBox"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tue"
android:layout_weight="1"
android:id="#+id/checkBox2"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Wed"
android:layout_weight="1"
android:id="#+id/checkBox3"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Thu"
android:layout_weight="1"
android:id="#+id/checkBox4"/>
I have tested your design in an activity , it's displaying fine in full screen.
[![like this][1]][1]
[1]: http://i.stack.imgur.com/0B1hz.png
Make sure you have given Fragment width and height to match parent.
<Fragment
android:width="match_parent"
android:height="match_parent"
/>
New androidtudio preview
And
the result on phone
Bellow is code modified as you suggested.
<?xml version="1.0" encoding="utf-8"?>
<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"
android:fitsSystemWindows="false"
tools:context=".MainFragment">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoText="false"
android:text="#string/getnotif"
android:layout_below="#+id/linearLayout2"
android:layout_centerHorizontal="true" />
<CheckBox
android:id="#+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/textView"
android:layout_alignStart="#+id/textView"
android:layout_below="#+id/textView"
android:text="#string/mcall"
android:textSize="12sp" />
<CheckBox
android:id="#+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView"
android:layout_toEndOf="#+id/checkBox"
android:layout_toRightOf="#+id/checkBox"
android:text="#string/msms"
android:textSize="12sp" />
<Button
android:id="#+id/timePicker"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="00:00"
android:background="#3f51b5"
android:layout_alignTop="#+id/timePicker2"
android:layout_marginLeft="25dp"
android:layout_alignParentStart="true"
android:textColor="#ffffff" />
<Button
android:id="#+id/timePicker2"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="23:59"
android:background="#3f51b5"
android:layout_below="#+id/linearLayout4"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="false"
android:layout_alignParentEnd="false"
android:layout_marginRight="25dp"
android:layout_alignParentRight="true"
android:textColor="#ffffff" />
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/timePicker"
android:layout_marginTop="20dp"
android:orientation="horizontal"
android:layout_alignParentEnd="true">
<TextView
android:id="#+id/textView8"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="0dp"
android:text="Days"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout"
android:orientation="vertical"
android:layout_alignRight="#+id/linearLayout"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<CheckBox
android:id="#+id/checkBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MON"
android:layout_weight="1" />
<CheckBox
android:id="#+id/checkBox4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TUE"
android:layout_weight="1"/>
<CheckBox
android:id="#+id/checkBox5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="WED"
android:layout_weight="1" />
<CheckBox
android:id="#+id/checkBox6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="THU"
android:layout_weight="1" />
<CheckBox
android:id="#+id/checkBox7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FRI"
android:layout_weight="1" />
<CheckBox
android:id="#+id/checkBox8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SAT"
android:layout_weight="1"/>
<CheckBox
android:id="#+id/checkBox9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SUN"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal">
<Button
android:id="#+id/exitButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/button_state"
android:text="Exit"
android:layout_weight="0.5"
android:layout_marginRight="16dp"
android:textColor="#ffffff" />
<Button
android:id="#+id/saveButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="#drawable/button_state"
android:text="Save"
android:layout_weight="0.5"
android:layout_marginLeft="16dp"
android:textColor="#ffffff" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="false"
android:layout_marginTop="20dp"
android:id="#+id/linearLayout4"
android:layout_alignParentEnd="false">
<TextView
android:id="#+id/textView7"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="#string/from"
android:layout_below="#+id/textView5"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="false"
android:gravity="center"
android:layout_marginTop="20dp"
android:layout_marginLeft="25dp" />
<TextView
android:id="#+id/textView23"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="0dp"
android:text="Time"
android:gravity="center"
android:layout_weight="1" />
<TextView
android:id="#+id/textView6"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="#string/to"
android:layout_below="#+id/textView5"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:gravity="center"
android:layout_marginTop="20dp"
android:layout_marginRight="25dp" />
</LinearLayout>
</RelativeLayout>
I didn't managed to align properly the text boxes under the check boxes.
I have inserted the layout into a scroll view and i can properly see all of them know.
It is good enough for me.

android app having different orientation for its items when changing the screen

My items on large screen like 10.1 works fine and every item in its position but if I change the screen to 4 or 3, some of my items disappear and some appear in large font related to the device screen, so I want it to appear all items on its correct positions so if the app run on small screen the font small and every thing in its normal position, also with large screen. So what I have to do to my xml to get my goal?
this is my xml :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="false"
android:fadingEdge="none"
android:background="#BFAF80"
android:scrollbars="none"
android:scrollbarSize="0dp"
android:paddingRight="0dp"
android:scrollbarAlwaysDrawVerticalTrack="false"
android:scrollbarStyle="insideOverlay"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#BFAF80"
android:id="#+id/CreatClear"
android:orientation="vertical">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/Bwt"
android:textStyle="bold"
android:gravity="center"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="29dp"
android:hint="#string/body_weight"
android:textColor="#e53f3f3f" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/Age"
android:textStyle="bold"
android:gravity="center"
android:hint="#string/age_years"
android:layout_below="#+id/Hit"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textColor="#e53f3f3f" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/Screat"
android:gravity="center"
android:textStyle="bold"
android:hint="#string/serum_creatinine"
android:layout_below="#+id/Age"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textColor="#e53f3f3f" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female"
android:id="#+id/Cfemale"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:textSize="#dimen/abc_text_size_medium_material"
android:layout_marginTop="28dp"
android:layout_below="#+id/Screat"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male"
android:id="#+id/Cmale"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:textSize="#dimen/abc_text_size_medium_material"
android:layout_below="#+id/Cfemale"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="64dp"
android:layout_height="64dp"
android:id="#+id/calcH"
android:background="#drawable/ic_launcher5"
android:clickable="false"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="64dp"
android:layout_height="64dp"
android:id="#+id/calc"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#drawable/ic_launcher"
android:clickable="true"
android:gravity="center" />
<TextView
android:layout_width="48dp"
android:layout_height="48dp"
android:text="Reset"
android:id="#+id/clearH"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:background="#drawable/ic_launcher5"
android:clickable="false"
android:gravity="center"
android:layout_alignBottom="#+id/sex"
android:layout_toLeftOf="#+id/sexa1"
android:layout_toStartOf="#+id/sexa1" />
<TextView
android:layout_width="48dp"
android:layout_height="48dp"
android:text="Reset"
android:id="#+id/clear"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:background="#drawable/ic_launcher3"
android:clickable="true"
android:gravity="center"
android:layout_alignTop="#+id/clearH"
android:layout_alignLeft="#+id/clearH"
android:layout_alignStart="#+id/clearH" />
<TextView
android:layout_width="48dp"
android:layout_height="48dp"
android:text="Menu"
android:id="#+id/menuH"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:background="#drawable/ic_launcher5"
android:clickable="false"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/sex"
android:layout_toEndOf="#+id/sex" />
<TextView
android:layout_width="48dp"
android:layout_height="48dp"
android:text="Menu"
android:id="#+id/menu"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:background="#drawable/ic_launcher3"
android:clickable="true"
android:gravity="center"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/sex"
android:layout_toEndOf="#+id/sex" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/Hit"
android:textStyle="bold"
android:gravity="center"
android:hint="#string/height_cm"
android:layout_below="#+id/Bwt"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textColor="#e53f3f3f"/>
<TextView
style="#style/TextAppearance.AppCompat.Medium"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/Serum"
android:gravity="center"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:textSize="#dimen/abc_text_size_large_material"
android:lines="#integer/abc_max_action_buttons"
android:autoText="false"
android:background="#color/ripple_material_dark"
android:layout_above="#+id/blank"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
style="#style/TextAppearance.AppCompat.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/newSerum"
android:gravity="center"
android:textColor="#e53f3f3f"
android:textStyle="bold"
android:textSize="#dimen/abc_text_size_large_material"
android:layout_above="#+id/calcH"
android:layout_centerHorizontal="true"
android:visibility="visible"
android:lines="#integer/abc_max_action_buttons"
android:background="#color/ripple_material_dark" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="nIBW"
android:id="#+id/nIBW"
android:layout_below="#+id/Cmale"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="15dp"
android:layout_marginEnd="15dp"
android:layout_marginTop="34dp"
android:visibility="invisible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="nABW"
android:id="#+id/nABW"
android:layout_alignBottom="#+id/nIBW"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:visibility="invisible" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/sex"
android:layout_alignTop="#+id/Cfemale"
android:layout_toRightOf="#+id/Screat"
android:layout_toEndOf="#+id/Screat"
android:gravity="center"
android:text="Gender"
android:visibility="invisible"
android:layout_alignParentLeft="true"
android:layout_marginLeft="0dp"
android:layout_alignParentTop="true"
android:layout_marginTop="604dp" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/sexa1"
android:gravity="center"
android:text="Gender1"
android:visibility="invisible"
android:layout_alignTop="#+id/Cfemale"
android:layout_alignRight="#+id/nIBW"
android:layout_alignEnd="#+id/nIBW" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/sexa2"
android:gravity="center"
android:text="Gender2"
android:visibility="invisible"
android:layout_alignTop="#+id/sexa1"
android:layout_alignRight="#+id/sexa1"
android:layout_alignEnd="#+id/sexa1" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="numberDecimal"
android:ems="10"
android:id="#+id/BSA"
android:gravity="center"
android:text="Body Surface Area"
android:visibility="invisible"
android:layout_below="#+id/Cmale"
android:layout_toLeftOf="#+id/nABW"
android:layout_toStartOf="#+id/nABW" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="#+id/blank"
android:layout_above="#+id/newSerum"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
style="#style/TextAppearance.AppCompat.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Creat Clear (ml/min)"
android:id="#+id/HSerum"
android:gravity="center"
android:textColor="#ffffffff"
android:textStyle="bold"
android:background="#color/background_material_dark"
android:textSize="#dimen/abc_text_size_large_material"
android:layout_alignTop="#+id/BSA"
android:layout_toRightOf="#+id/Screat"
android:layout_toEndOf="#+id/Screat"
android:visibility="invisible" />
</RelativeLayout>
</ScrollView>
Create a some resource directories called values-swXXXdp in res folder where XXX means smallest screen witdh.
In each directory create a file called dimens.xml and define the dimension for each swXXXdp:
<dimen name="custom_width">40dp</dimen>
Then, to retrieve that value in xml do the following: for example the width of a view:
android:layout_width="#dimen/custom_width"

Set object correctly in a layout

I have the following XML layout:
<?xml version="1.0" encoding="utf-8"?>
<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"
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=".MainActivity"
android:background="#layout/bginset2" >
<TextView
android:id="#+id/tvTripName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Trip Name:"
android:textStyle="bold"
android:textColor="#2B00E4"
android:layout_above="#+id/etShowLog"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:paddingLeft="2dip" />
<EditText
android:id="#+id/etFileName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="#+id/tvTripName"
android:ems="10"
android:inputType="textNoSuggestions"
android:paddingLeft="2dip"
android:singleLine="true"
android:textColor="#999999"
android:textSize="14dip"
android:textStyle="normal" />
<EditText
android:id="#+id/etShowLog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textMultiLine|textNoSuggestions"
android:lines="20"
android:textStyle="normal"
android:paddingLeft="2dip"
android:singleLine="false"
android:textColor="#999999"
android:textSize="14dip"
android:gravity="top"
android:layout_above="#+id/btnClear" />
<Button
android:id="#+id/btnClear"
android:background="#drawable/otherbuttons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Clear Trip"
android:textStyle="bold"
android:textColor="#FFFFFF"
android:shadowColor="#000000"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:layout_alignParentBottom="true" />
<Button
android:id="#+id/btnSave"
android:background="#drawable/otherbuttons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save Trip"
android:layout_gravity="right"
android:textStyle="bold"
android:textColor="#FFFFFF"
android:shadowColor="#000000"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true" />
</RelativeLayout>
It shows up on my phone like this:
Why does the Trip Name appear so low and why is the text so close to the left?
How do I fix it?
It looks like you have conflicting properties in your EditText
<EditText
android:id="#+id/etFileName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textMultiLine|textNoSuggestions"
android:lines="22"
android:textStyle="normal"
android:paddingLeft="2dip"
android:singleLine="false"
android:textColor="#999999"
android:textSize="14dip"
android:layout_toLeftOf="#+id/tvTripName" // here
android:layout_alignParentRight="true" // and here
You are telling it to be to the left of your TextView which is aligned left but also telling it to be aligned right of parent.
you can keep your cursor according to your choice by using this
EditText.setSelection(int index)
and for Trip name..just put Textview and edittext inside one layout
like
<?xml version="1.0" encoding="utf-8"?>
<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" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/tvTripName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="2dip"
android:text="Trip Name:"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#2B00E4"
android:textStyle="bold" />
<EditText
android:id="#+id/etFileName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textNoSuggestions"
android:paddingLeft="2dip"
android:singleLine="true"
android:textColor="#999999"
android:textSize="14dip"
android:textStyle="normal" />
</LinearLayout>
<EditText
android:id="#+id/etShowLog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/btnClear"
android:ems="10"
android:gravity="top"
android:inputType="textMultiLine|textNoSuggestions"
android:lines="20"
android:paddingLeft="2dip"
android:singleLine="false"
android:textColor="#999999"
android:textSize="14dip"
android:textStyle="normal" />
<Button
android:id="#+id/btnClear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#drawable/ic_launcher"
android:shadowColor="#000000"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:text="Clear Trip"
android:textColor="#FFFFFF"
android:textStyle="bold" />
<Button
android:id="#+id/btnSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:background="#drawable/ic_launcher"
android:shadowColor="#000000"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="2"
android:text="Save Trip"
android:textColor="#FFFFFF"
android:textStyle="bold" />
</RelativeLayout>
Hope this will work for u..

Seekbar too little

I'm following an example in my book, but I can't get the seekbar in the said example to be large enough as the book shows and even the example code from the book site shows.
this is the layout declaration and the concerned row. Do you know what is the difference related to?
Expected Result and given result (yes the book was made for 2.3):
http://i.stack.imgur.com/9QT9j.png
http://i.stack.imgur.com/J7Cpr.png
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tableLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFF"
android:padding="5dp"
android:stretchColumns="1,2,3" >
<TableRow
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="#+id/tableRow0">
<TextView
android:id="#+id/billTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/billTotal"
android:textColor="#000"
android:gravity="right"
android:paddingRight="5dp" />
<EditText
android:id="#+id/billEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_span="3"
android:inputType="numberDecimal"
android:layout_weight="1">
</EditText>
</TableRow>
<TableRow
android:id="#+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/tenTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:textColor="#000"
android:gravity="center"
android:layout_weight="1"
android:text="10%" />
<TextView
android:id="#+id/fifteenTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="15%"
android:textColor="#000"
android:gravity="center"
android:layout_weight="1"/>
<TextView
android:id="#+id/twentyTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="20%"
android:textColor="#000"
android:gravity="center"
android:layout_weight="1"/>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/tipTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:paddingRight="5dp"
android:text="#string/tip" />
<EditText
android:id="#+id/tip10EditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:longClickable="false"
android:text="#string/zero" />
<EditText
android:id="#+id/tip15EditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:focusable="false"
android:longClickable="false"
android:text="#string/zero" />
<EditText
android:id="#+id/tip20EditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:focusable="false"
android:longClickable="false"
android:text="#string/zero" />
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/totalTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:paddingRight="5dp"
android:text="#string/total" />
<EditText
android:id="#+id/total10EditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:focusable="false"
android:longClickable="false"
android:text="#string/zero" />
<EditText
android:id="#+id/total15EditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:focusable="false"
android:longClickable="false"
android:text="#string/zero" />
<EditText
android:id="#+id/total20EditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:focusable="false"
android:longClickable="false"
android:text="#string/zero" />
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="#+id/tableRow4">
<TextView
android:id="#+id/customTextView"
android:layout_width="wrap_content"
android:text="#string/custom"
android:textColor="#000"
android:paddingRight="5dp"
android:gravity="right|center_vertical"
android:layout_height="match_parent"
android:paddingBottom="5dp"
android:focusable="false"/>
<SeekBar
android:id="#+id/customSeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_span="2"
android:layout_weight="1"
android:paddingBottom="5dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:progress="18" />
<TextView
android:id="#+id/customTipTextView"
android:layout_width="wrap_content"
android:text="18%"
android:textColor="#000"
android:gravity="center_vertical"
android:layout_height="match_parent"
android:paddingLeft="5dp"
android:paddingBottom="5dp"
android:focusable="false"
android:layout_weight="1"
/>
</TableRow>
<TableRow
android:id="#+id/tableRow5"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/tipCustomTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:paddingRight="5dp"
android:text="#string/tip" />
<EditText
android:id="#+id/tipCustomEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:focusable="false"
android:longClickable="false"
android:text="#string/zero" />
<TextView
android:id="#+id/totalCustomTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:layout_weight="1"
android:paddingRight="5dp"
android:text="#string/total" />
<EditText
android:id="#+id/totalCustomEditText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:focusable="false"
android:longClickable="false"
android:text="#string/zero" />
</TableRow>
</TableLayout>

Categories