Wrap content not working and scroll stopped working.
Hi, I'm developing an app for Android and I have noticed that my app works perfectly in smartphones, however in Tablets in Portrait mode it adds a huge space and the ScrollView stops working.
Smartphone's view:
Tablet's view:
My XML code:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/descAbout"
android:layout_marginBottom="10dp"
android:textSize="16sp"
android:layout_marginTop="10dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_marginBottom="10dp"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true">
<ImageView
android:id="#+id/imgSpaceApps"
android:layout_width="wrap_content"
android:layout_height="115dp"
android:adjustViewBounds="true"
android:layout_gravity="center"
android:src="#drawable/spaceApps" />
<ImageView
android:id="#+id/imgNasaLogo"
android:layout_width="wrap_content"
android:layout_height="115dp"
android:adjustViewBounds="true"
android:layout_gravity="center"
android:src="#drawable/nasaLogo" />
</LinearLayout>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="#string/lblContact2"
android:layout_marginBottom="5dp" />
<TextView
android:id="#+id/lblOurEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="#string/lblContactUs"
android:clickable="true"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="#string/lblVisit"
android:autoLink="web"
android:layout_marginBottom="5dp" />
<TextView
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="#string/lblSpecialGreeting"
android:layout_marginBottom="5dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:autoLink="web"
android:text="#string/url7"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:autoLink="web"
android:text="#string/url8"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:autoLink="web"
android:text="#string/url6"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:autoLink="web"
android:text="#string/url5"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:autoLink="web"
android:text="#string/url1"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:autoLink="web"
android:text="#string/url2"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:autoLink="web"
android:text="#string/url3"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:autoLink="web"
android:text="#string/url4"
android:layout_marginBottom="10dp" />
<TextView
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="#string/lblPPrivacy"
android:layout_marginBottom="5dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:autoLink="web"
android:text="#string/url9"
android:layout_marginBottom="10dp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_marginBottom="5dp"
android:adjustViewBounds="true"
android:layout_gravity="center"
android:src="#drawable/supernova" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textSize="14sp"
android:text="#string/About6"
android:layout_marginBottom="10dp" />
</LinearLayout>
</ScrollView>
If I remove the properties of:
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
The result is the same:
I am testing in Android 6 and 7, also, the minimum SDK is 21.
Does anyone have experienced this situation? Thanks for your help.
As mentioned in my comment the cause is the RelativeLayout that holds the images.
RelativeLayout can cause unexpected results when used with 'wrap_content' where it will actually try to match its parent and lay out the children at the edges.
In this case, the RelativeLayout is pretty useless anyway; you can remove it and slightly change the attributes of the child LinearLayout:
...
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:gravity="center_horizontal"
>
<ImageView
android:id="#+id/imgSpaceApps"
android:layout_width="wrap_content"
android:layout_height="115dp"
android:adjustViewBounds="true"
android:src="#drawable/spaceApps" />
<ImageView
android:id="#+id/imgNasaLogo"
android:layout_width="wrap_content"
android:layout_height="115dp"
android:adjustViewBounds="true"
android:src="#drawable/nasaLogo" />
</LinearLayout>
...
Change it to this :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/descAbout"
android:layout_marginBottom="10dp"
android:textSize="16sp"
android:layout_marginTop="10dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_marginBottom="10dp"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true">
<ImageView
android:id="#+id/imgSpaceApps"
android:layout_width="wrap_content"
android:layout_height="115dp"
android:adjustViewBounds="true"
android:layout_gravity="center"
android:src="#drawable/spaceApps" />
<ImageView
android:id="#+id/imgNasaLogo"
android:layout_width="wrap_content"
android:layout_height="115dp"
android:adjustViewBounds="true"
android:layout_gravity="center"
android:src="#drawable/nasaLogo" />
</LinearLayout>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="#string/lblContact2"
android:layout_marginBottom="5dp" />
<TextView
android:id="#+id/lblOurEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="#string/lblContactUs"
android:clickable="true"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="#string/lblVisit"
android:autoLink="web"
android:layout_marginBottom="5dp" />
<TextView
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="#string/lblSpecialGreeting"
android:layout_marginBottom="5dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:autoLink="web"
android:text="#string/url7"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:autoLink="web"
android:text="#string/url8"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:autoLink="web"
android:text="#string/url6"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:autoLink="web"
android:text="#string/url5"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:autoLink="web"
android:text="#string/url1"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:autoLink="web"
android:text="#string/url2"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:autoLink="web"
android:text="#string/url3"
android:layout_marginBottom="10dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:autoLink="web"
android:text="#string/url4"
android:layout_marginBottom="10dp" />
<TextView
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:text="#string/lblPPrivacy"
android:layout_marginBottom="5dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16sp"
android:autoLink="web"
android:text="#string/url9"
android:layout_marginBottom="10dp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_marginBottom="5dp"
android:adjustViewBounds="true"
android:layout_gravity="center"
android:src="#drawable/supernova" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textSize="14sp"
android:text="#string/About6"
android:layout_marginBottom="10dp" />
</LinearLayout>
</ScrollView>
Related
I've created a preference UI but the thing is I can't let the bottommost child view to be displayed on the device. It keeps discarding the bottommost view. Though this query is similar to one I found in the query list yet the problem I'm facing left me with no debugging ways or I'm missing some serious property.
My code is:
The Bottom TextView which I finally wrapped inside a relativeView is the part which is discarded.
To ,y wonder I changed to LinearLayout from Relative built I guess It might have some issues as well..
But the most important query is that it doesn't scroll till the end of the Activity.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context=".Preferences">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#color/colorPrimary"
android:id="#+id/header"
enter code here
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/back_key"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/text_prefer"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:text="#string/activity_name"
android:textColor="#color/white"
android:textStyle="bold"
android:textSize="18sp"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/wrapper_scroll"
android:layout_below="#id/header"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/scroll_horizontal"
android:fillViewport="true"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginLeft="11dp"
android:layout_marginRight="11dp"
android:id="#+id/rel_scroll"
android:layout_marginBottom="10dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="120dp"
android:background="#drawable/rounded_back_for_layout"
android:id="#+id/rel_age_layout"
android:layout_marginBottom="5dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="18dp"
android:id="#+id/age_text"
android:text="#string/age"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="#color/magenta_brown"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="18dp"
android:layout_alignParentRight="true"
android:text="18-26"
android:textStyle="bold"
android:textSize="14sp"
android:textColor="#color/black"
/>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/text_age_pref"
android:layout_below="#id/rel_age_layout"
android:text="#string/age_prefer"
android:textSize="10.5sp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="45dp"
android:layout_below="#id/rel_age_layout"
android:background="#drawable/rounded_back_for_layout"
android:id="#+id/rel_interest_layout"
android:layout_marginBottom="5dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:id="#+id/interested_in_text"
android:text="#string/interested_in"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="#color/magenta_brown"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="18dp"
android:layout_below="#id/interested_in_text"
android:text="#string/men"
android:textSize="14sp"
android:textColor="#color/black"
android:id="#+id/men"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="18dp"
android:layout_below="#id/men"
android:layout_marginTop="10dp"
android:text="#string/women"
android:textSize="14sp"
android:textColor="#color/black"
android:layout_marginBottom="10dp"
/>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/interested_pref"
android:layout_below="#id/rel_interest_layout"
android:text="#string/interested_prefer"
android:textSize="10.5sp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="38dp"
android:layout_below="#id/rel_interest_layout"
android:background="#drawable/rounded_back_for_layout"
android:id="#+id/rel_alerts_layout"
android:layout_marginBottom="5dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="18dp"
android:id="#+id/alerts_mode"
android:text="#string/alerts"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="#color/magenta_brown"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="18dp"
android:layout_below="#id/alerts_mode"
android:text="#string/sound"
android:textSize="14sp"
android:layout_marginBottom="14dp"
android:textColor="#color/black"
/>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/sound_prefer"
android:layout_below="#id/rel_alerts_layout"
android:textSize="10.5sp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="45dp"
android:layout_marginBottom="5dp"
android:layout_below="#id/rel_alerts_layout"
android:background="#drawable/rounded_back_for_layout"
android:id="#+id/rel_matchmaker_layout"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="18dp"
android:id="#+id/matchmaker_text"
android:text="#string/matchmaker"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="#color/magenta_brown"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="18dp"
android:layout_below="#id/matchmaker_text"
android:text="#string/hide_my_prof"
android:textSize="14sp"
android:textColor="#color/black"
android:layout_marginBottom="10dp"
/>
</RelativeLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/matchmaker_prefer"
android:text="#string/matchmaker_prefer"
android:layout_below="#id/rel_matchmaker_layout"
android:textSize="12sp"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="38dp"
android:layout_below="#id/rel_matchmaker_layout"
android:background="#drawable/rounded_back_for_layout"
android:id="#+id/rel_whitelist_layout"
android:layout_marginBottom="10dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="18dp"
android:id="#+id/whitelist_text"
android:text="#string/whitelist"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="#color/magenta_brown"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="18dp"
android:layout_alignParentRight="true"
android:text="#string/go"
android:padding="10dp"
android:background="#drawable/edittext_rectangle_border"
android:textStyle="bold"
android:textSize="14sp"
android:textColor="#color/black"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/rel_whitelist_layout"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10.5sp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:text="#string/whitelist_prefer"
/>
</RelativeLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
</RelativeLayout>
Here's the screenshot:
Try changing the height of the ScrollView from match_parent to wrap_content:
<ScrollView
...
android:layout_height="wrap_content"
... >
I tried your xml and this worked.
Add this to your last TextView
android:layout_margin="18dp"
Your last element will be:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/rel_whitelist_layout">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10.5sp"
android:layout_marginLeft="3dp"
android:layout_marginRight="3dp"
android:layout_margin="18dp"
android:text="#string/whitelist_prefer"/>
</RelativeLayout>
I am not able to find out the exact issue that why the image(background) is not visible in API level 16 but it is showing good in API level 19. I have worked simply as i have done previously but , this time the background is not shown(of WaterMark in ImageView).
I am not able to find out what is exact issue . So i need help.I have done every thing as suggested in the stack Android device is not showing the background image but it is not going good in my case.
xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout 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:orientation="vertical">
<ScrollView
android:id="#+id/scrollLogin"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/rlGetInTouch"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#304EA2">
<RelativeLayout
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/header_bg2">
<ImageView
android:id="#+id/brand"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/nbl_logo4" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#304EA2">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginBottom="35dp"
android:layout_marginTop="-60dp"
android:color="#android:color/transparent"
android:src="#drawable/logowatermark" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/edit_text_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingLeft="35dp"
android:paddingRight="35dp">
<******.CustomFontLoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:text=" Please login to proceed"
android:textColor="#color/white"
android:textSize="12sp"
android:textStyle="normal" />
<******.CustomFontEditText
android:id="#+id/etUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:background="#drawable/edit_text_border"
android:drawablePadding="8dp"
android:gravity="center"
android:hint="Mobile Number"
android:inputType="number"
android:maxLength="#integer/mobile_length"
android:padding="13dp"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="12dp"
android:textStyle="bold" />
<******.CustomFontEditText
android:id="#+id/etPassword"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="12dp"
android:layout_toLeftOf="#+id/passwordVisibilityBtn"
android:background="#drawable/edit_text_border"
android:drawablePadding="8dp"
android:gravity="center"
android:hint="Password"
android:inputType="textPassword"
android:maxLength="#integer/password_length"
android:padding="13dp"
android:textCursorDrawable="#drawable/color_cursor"
android:textSize="12dp"
android:textStyle="bold" />
<******.CustomFontCheckBox
android:id="#+id/chkSaveUsername"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:button="#drawable/custom_checkbox"
android:drawablePadding="5dp"
android:gravity="center"
android:text=" Remember Mobile No."
android:textColor="#color/white"
android:textSize="12sp"
android:textStyle="normal" />
<LinearLayout
android:id="#+id/loginLl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#drawable/login_button_shadow"
android:orientation="vertical">
<******.CustomFontLoginTextView
android:id="#+id/btnLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#drawable/login_button_new1"
android:clickable="true"
android:gravity="center"
android:padding="13dp"
android:text="Login"
android:textAllCaps="true"
android:textColor="#color/white"
android:textSize="14sp" />
<******.CustomFontLoginTextView
android:id="#+id/action_sms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:background="#drawable/login_button_new1"
android:clickable="true"
android:gravity="center"
android:paddingBottom="10dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:paddingTop="10dp"
android:text="Switch To SMS"
android:textColor="#color/white"
android:textSize="12sp" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<******.CustomFontLoginTextView
android:id="#+id/resetDeviceId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:alpha="0.7"
android:drawableLeft="#drawable/icon_reset_20"
android:drawablePadding="3dp"
android:gravity="center"
android:text="#string/reset_device_id_text"
android:textColor="#color/white"
android:textSize="12sp" />
<******.CustomFontLoginTextView
android:id="#+id/action_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:alpha="0.7"
android:drawableLeft="#drawable/icon_info_20"
android:drawablePadding="3dp"
android:gravity="center"
android:text="#string/info"
android:textColor="#color/white"
android:textSize="12sp" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<!-- Promo -->
<LinearLayout
android:id="#+id/llPromotions"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/promo_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/llBranches"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/rlLogin"
android:layout_gravity="center"
android:background="#304EA2"
android:gravity="center"
android:orientation="horizontal"
android:padding="15dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:onClick="showATMs"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:padding="2dp"
android:src="#drawable/icon_atm_50_6" />
<******.CustomFontLoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="8dp"
android:text="ATM"
android:textColor="#FFFFFF"
android:textSize="12sp" />
<******.CustomFontLoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="3dp"
android:text="Locate nearest Atm Machines"
android:textColor="#FFFFFF"
android:textSize="8sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:clickable="true"
android:onClick="showBranches"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="2dp"
android:src="#drawable/ic_branches_50_6" />
<******.CustomFontLoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingTop="8dp"
android:text="BRANCHES"
android:textColor="#FFFFFF"
android:textSize="12sp" />
<******.CustomFontLoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="3dp"
android:text="Locate nearest bank branches"
android:textColor="#FFFFFF"
android:textSize="8sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:onClick="showRates"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="2dp"
android:src="#drawable/ic_rates_50_6" />
<******.CustomFontLoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="8dp"
android:text="RATES"
android:textColor="#FFFFFF"
android:textSize="12sp" />
<******.CustomFontLoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="3dp"
android:text="Foreign exchange and stock rates"
android:textColor="#FFFFFF"
android:textSize="8sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/rlProducts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:orientation="vertical">
<******.CustomFontLoginTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:text="Products"
android:textAllCaps="true"
android:textColor="#color/gray"
android:textSize="14sp" />
<!--Product Container-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<!--Product 1-->
<LinearLayout
android:id="#+id/product_content1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="7.5dp"
android:layout_weight="1"
android:orientation="vertical" />
<!--Product 2-->
<LinearLayout
android:id="#+id/product_content2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="7.5dp"
android:layout_marginRight="15dp"
android:layout_weight="1"
android:gravity="end"
android:orientation="vertical" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/rlGetInTouch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#304EA2"
android:orientation="horizontal">
<CustomFontLoginTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/btnCall"
android:paddingLeft="15dp"
android:singleLine="true"
android:text="Get in touch with us"
android:textColor="#color/white"
android:textSize="16sp"
android:textStyle="normal" />
<!--app:maxTextSize="14sp"
app:minTextSize="#dimen/minFontSize"-->
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/btnMap"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dp"
android:onClick="showLocation"
android:src="#drawable/ic_action_location_24_4" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/btnEmail"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/btnMap"
android:layout_toStartOf="#+id/btnMap"
android:onClick="openEmail"
android:src="#drawable/ic_action_mail_24_4" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/btnCall"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentTop="true"
android:layout_toLeftOf="#+id/btnEmail"
android:layout_toStartOf="#+id/btnEmail"
android:onClick="openCall"
android:src="#drawable/ic_action_call_24_4" />
</RelativeLayout>
</RelativeLayout>
The Image background of watermark is not shown. I have done nothing
new ,same as previous but dont' know that is the exact issue.
Please reduce image size to visible in the lower level device.
I Just Removed marginTop and it worked fine in API level 16
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginBottom="35dp"
android:src="#drawable/logowatermark" />
I don't understand that why it worked when i remove the -ve marginTop
in above? .I got solution but don't understand what exactly happened
in adding -ve marginTop and with removing -ve marginTop.
I am facing 2 issues
1.My text view is overlapping. ID is textView7 and name is OrderStatus
2.I am trying to add the divider using the view it is also not working
NOTE:divider is working i have added the android:layout_below property
MyActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
tools:context="com.example.lenovo.jdstudio.UpdateOrderStatusActivity">
<android.support.v7.widget.Toolbar
android:id="#+id/updateOrderToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:orientation="vertical"
android:theme="#style/ThemeOverlay.AppCompat.Dark" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/Fname_LinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dimen_10dp"
android:layout_marginTop="#dimen/dimen_10dp"
android:orientation="horizontal">
<TextView
android:id="#+id/textView2"
android:layout_width="105dp"
android:layout_height="wrap_content"
android:text="First Name "
android:textAllCaps="true"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/Update_FName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dimen_25dp"
android:freezesText="true"
android:gravity="center_horizontal"
android:text="Aakash"
android:textColor="#color/color_3"
android:textSize="16sp"
android:textStyle="normal|italic" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray"
android:layout_marginTop="#dimen/dimen_5dp"
android:layout_below="#id/Fname_LinearLayout"/>
<LinearLayout
android:id="#+id/Lname_LinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/Fname_LinearLayout"
android:layout_marginLeft="#dimen/dimen_10dp"
android:layout_marginTop="#dimen/dimen_15dp"
android:orientation="horizontal">
<TextView
android:id="#+id/textView3"
android:layout_width="105dp"
android:layout_height="wrap_content"
android:text="Last Name :"
android:textAllCaps="true"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/Update_LName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dimen_25dp"
android:text="Bidlan"
android:textColor="#color/color_3"
android:textSize="16sp"
android:textStyle="italic" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="#dimen/dimen_5dp"
android:layout_below="#id/Lname_LinearLayout"
android:background="#android:color/darker_gray" />
<LinearLayout
android:id="#+id/orderStatus_LinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/Lname_LinearLayout"
android:layout_marginLeft="#dimen/dimen_10dp"
android:layout_marginTop="#dimen/dimen_15dp"
android:orientation="horizontal"
android:layout_marginBottom="#dimen/dimen_2dp">
<TextView
android:id="#+id/textView7"
android:layout_width="105dp"
android:layout_height="wrap_content"
android:text="Order Status"
android:textAllCaps="true"
android:textSize="16sp"
android:textStyle="bold" />
<Spinner
android:id="#+id/orderStatusSpinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dimen_25dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="#dimen/dimen_5dp"
android:layout_below="#id/orderStatus_LinearLayout"
android:background="#android:color/darker_gray" />
<LinearLayout
android:id="#+id/email_LinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/orderStatus_LinearLayout"
android:layout_marginLeft="#dimen/dimen_10dp"
android:layout_marginTop="#dimen/dimen_15dp"
android:orientation="horizontal">
<TextView
android:id="#+id/textView4"
android:layout_width="105dp"
android:layout_height="wrap_content"
android:text="Email"
android:textAllCaps="true"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/UpdateOrderEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dimen_25dp"
android:text="123#gmail.com"
android:textColor="#color/color_3"
android:textSize="16sp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray"
android:layout_marginTop="#dimen/dimen_5dp"
android:layout_below="#id/email_LinearLayout"/>
<LinearLayout
android:id="#+id/phoneno_LinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/email_LinearLayout"
android:layout_marginLeft="#dimen/dimen_10dp"
android:layout_marginTop="#dimen/dimen_15dp"
android:orientation="horizontal">
<TextView
android:id="#+id/textView5"
android:layout_width="105dp"
android:layout_height="wrap_content"
android:text="Phone No."
android:textAllCaps="true"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/update_phoneNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dimen_25dp"
android:text="1234567890"
android:textColor="#color/color_3"
android:textSize="16sp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray"
android:layout_marginTop="#dimen/dimen_5dp"
android:layout_below="#id/phoneno_LinearLayout"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/phoneno_LinearLayout"
android:layout_marginLeft="#dimen/dimen_10dp"
android:layout_marginTop="#dimen/dimen_15dp">
<TextView
android:id="#+id/textView6"
android:layout_width="105dp"
android:layout_height="wrap_content"
android:text="Photo Description"
android:textAllCaps="true"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/Update_photoDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dimen_25dp"
android:text="id passport"
android:textColor="#color/color_3"
android:textSize="16sp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
<Button
android:id="#+id/UpdateOrderSatatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="7dp"
android:text="Update Order" />
<Button
android:id="#+id/deleteOrder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/UpdateOrderSatatus"
android:layout_alignParentStart="true"
android:layout_marginBottom="88dp"
android:text="Delete Order" />
<ProgressBar
android:id="#+id/updateOrderProgress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</LinearLayout>
I tried giving bottom padding first and then bottom margin. it doesn't work.
Thanks for reading the Question.
waiting for the favorable reply...
I have made some changes in this XML file Please try this :-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
tools:context=".MainActivity">
<android.support.v7.widget.Toolbar
android:id="#+id/updateOrderToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:orientation="vertical"
android:theme="#style/ThemeOverlay.AppCompat.Dark" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/Fname_LinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="4dp"
android:orientation="horizontal">
<TextView
android:id="#+id/textView2"
android:layout_width="105dp"
android:layout_height="wrap_content"
android:text="First Name"
android:layout_gravity="center"
android:textAllCaps="true"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/Update_FName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="25dp"
android:freezesText="true"
android:gravity="center_horizontal"
android:text="Aakash"
android:textColor="#000"
android:textSize="16sp"
android:textStyle="normal|italic" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
<LinearLayout
android:id="#+id/Lname_LinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/Fname_LinearLayout"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="4dp"
android:orientation="horizontal">
<TextView
android:id="#+id/textView3"
android:layout_width="105dp"
android:layout_height="wrap_content"
android:text="Last Name"
android:textAllCaps="true"
android:layout_gravity="center"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/Update_LName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:text="Bidlan"
android:textColor="#000"
android:layout_gravity="center"
android:textSize="16sp"
android:textStyle="italic" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
<LinearLayout
android:id="#+id/orderStatus_LinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/Lname_LinearLayout"
android:layout_marginBottom="4dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:orientation="horizontal">
<TextView
android:id="#+id/textView7"
android:layout_width="105dp"
android:layout_height="wrap_content"
android:text="Order Status"
android:layout_gravity="center"
android:textAllCaps="true"
android:textSize="16sp"
android:textStyle="bold" />
<Spinner
android:id="#+id/orderStatusSpinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
<LinearLayout
android:id="#+id/email_LinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/orderStatus_LinearLayout"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="4dp"
android:orientation="horizontal">
<TextView
android:id="#+id/textView4"
android:layout_width="105dp"
android:layout_height="wrap_content"
android:text="Email"
android:textAllCaps="true"
android:layout_gravity="center"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/UpdateOrderEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:text="123#gmail.com"
android:textColor="#000"
android:textSize="16sp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
<LinearLayout
android:id="#+id/phoneno_LinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/email_LinearLayout"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="4dp"
android:orientation="horizontal">
<TextView
android:id="#+id/textView5"
android:layout_width="105dp"
android:layout_height="wrap_content"
android:text="Phone No."
android:textAllCaps="true"
android:layout_gravity="center"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/update_phoneNumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:text="1234567890"
android:textColor="#000"
android:textSize="16sp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/phoneno_LinearLayout"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp">
<TextView
android:id="#+id/textView6"
android:layout_width="105dp"
android:layout_height="wrap_content"
android:text="Photo Description"
android:layout_gravity="center"
android:textAllCaps="true"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/Update_photoDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:text="id passport"
android:layout_gravity="center"
android:textColor="#000"
android:textSize="16sp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/darker_gray" />
<Button
android:id="#+id/UpdateOrderSatatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="7dp"
android:text="Update Order" />
<Button
android:id="#+id/deleteOrder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/UpdateOrderSatatus"
android:layout_alignParentStart="true"
android:layout_marginBottom="88dp"
android:text="Delete Order" />
<ProgressBar
android:id="#+id/updateOrderProgress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
</LinearLayout>
</LinearLayout>
There are too many rows for one screen in a non-scrollable layout. You should add a ScrollView to avoid problems with shorter screens or split the views in several ViewGroups / screens (for example by using some collapsible containers or ViewPager).
If that is not possible you could set weights to the TextViews' height and use the auto size text
<TextView
android:layout_width="105dp"
android:layout_height="0dp"
android:layout_weight="1"
android:autoSizeTextType="uniform" />
Also consider using a layout that is more suitable for the design, such as GridLayout or ConstraintLayout to avoid hard coding the TextView width.
I am developing an app which i have to divide the cardview to 2 parts.
I have done this :
But i want to move my blue button to top as this image shows below and change the background color to grey :
This my custom layout code :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:background="#color/Grey_300"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:layout_height="wrap_content"
app:cardBackgroundColor="#color/Grey_50"
app:cardCornerRadius="3dp"
card_view:cardCornerRadius="0dp">
<RelativeLayout
android:layoutDirection="ltr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<ImageView
android:id="#+id/imageview_video"
android:layout_width="150dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_height="100dp" />
<TextView
android:id="#+id/txt_overimage"
android:paddingRight="5dp"
android:paddingLeft="5dp"
android:paddingBottom="2dp"
android:paddingTop="2dp"
android:background="#color/myred"
android:textColor="#color/white"
android:textStyle="bold"
android:textSize="14sp"
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:id="#+id/txt_amazon_title"
android:layout_toRightOf="#+id/imageview_video"
android:layout_toEndOf="#+id/imageview_video"
android:layout_width="wrap_content"
android:textSize="15sp"
android:maxLength="100"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/txt_datetimevideo"
android:layout_toRightOf="#+id/imageview_video"
android:layout_toEndOf="#+id/imageview_video"
android:textColor="#color/Grey_500"
android:layout_below="#+id/txt_amazon_title"
android:textSize="14sp"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="#+id/bt_deal"
android:text="Voir le deal"
android:backgroundTint="#drawable/back_amazon"
android:textColor="#color/white"
android:textSize="14sp"
android:layout_below="#+id/txt_datetimevideo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<View
android:id="#+id/view_video"
android:layout_below="#+id/bt_deal"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"
android:layout_marginTop="10dp"
/>
<ImageView
android:id="#+id/favorite"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="5dp"
android:layout_marginEnd="5dp"
android:layout_marginTop="5dp"
android:layout_below="#+id/view_video"
android:background="#drawable/favorite"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</ScrollView>
</LinearLayout>
How can i do that ? Should i create another linearLayout and add the button inside the linearlayout ?
My updated code and image after adding linearlayout inside cardview :
updated code :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:background="#color/Grey_300"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:layout_height="wrap_content"
app:cardBackgroundColor="#color/Grey_50"
app:cardCornerRadius="3dp"
card_view:cardCornerRadius="0dp">
<LinearLayout
android:id="#+id/linear2"
android:background="#color/Grey_300"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/rela1"
android:background="#color/Grey_300"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="#+id/bt_deal2"
android:text="Voir le deal"
android:backgroundTint="#drawable/back_amazon"
android:textColor="#color/white"
android:textSize="14sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:layoutDirection="ltr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<ImageView
android:id="#+id/imageview_video"
android:layout_width="150dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_height="100dp" />
<TextView
android:id="#+id/txt_overimage"
android:paddingRight="5dp"
android:paddingLeft="5dp"
android:paddingBottom="2dp"
android:paddingTop="2dp"
android:background="#color/myred"
android:textColor="#color/white"
android:textStyle="bold"
android:textSize="14sp"
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:id="#+id/txt_amazon_title"
android:layout_toRightOf="#+id/imageview_video"
android:layout_toEndOf="#+id/imageview_video"
android:layout_width="wrap_content"
android:textSize="15sp"
android:maxLength="100"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_height="wrap_content" />
<TextView
android:id="#+id/txt_datetimevideo"
android:layout_toRightOf="#+id/imageview_video"
android:layout_toEndOf="#+id/imageview_video"
android:textColor="#color/Grey_500"
android:layout_below="#+id/txt_amazon_title"
android:textSize="14sp"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="#+id/bt_deal"
android:text="I HIDE BUTTON FOR REMOVING AFTER"
android:backgroundTint="#drawable/back_amazon"
android:textColor="#color/white"
android:textSize="14sp"
android:visibility="gone"
android:layout_below="#+id/txt_datetimevideo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<View
android:id="#+id/view_video"
android:layout_below="#+id/bt_deal"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?android:attr/listDivider"
android:layout_marginTop="10dp"
/>
<ImageView
android:id="#+id/favorite"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="5dp"
android:layout_marginEnd="5dp"
android:layout_marginTop="5dp"
android:layout_below="#+id/view_video"
android:background="#drawable/favorite"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</ScrollView>
</LinearLayout>
Try adding both your linearlayouts inside a parent linearlayout with orientation vertical.
I have a relative layout which contains two linear layouts. I want these two linear layouts to be placed in either halves of the relative layout containing them i.e. one to be positioned at top half and other at bottom half. Can anyone here help me with this. Here is the xml:
<RelativeLayout
android:id="#+id/updatedetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:orientation="vertical"
android:background="#drawable/oneeventbkg" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/Top_half_layout">
<ImageView
android:id="#+id/update_sn_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="2dp" />
<TextView
android:id="#+id/update_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_margin="5dp"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageView
android:id="#+id/update_message_pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/update_sn_icon"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp" />
<TextView
android:id="#+id/update_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/update_message_pic"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:maxHeight="400dp"
android:scrollbars="vertical"
android:textColor="#android:color/white"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:id="#+id/bottom_half_layout">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp"
android:id="#+id/toggle_after"
android:visibility="invisible">
<TextView
android:id="#+id/toggle_like_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:text="1000"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/toggle_like_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_like_button_selctor" />
<TextView
android:id="#+id/toggle_comment_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="7dp"
android:text="100"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/toggle_comment_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_comment_button_selector" />
</LinearLayout>
<ListView
android:id="#+id/likes_list"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_below="#id/toggle_after"
android:padding="20dp"
/>
<ListView
android:id="#+id/comments_list"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_below="#id/toggle_after"
android:padding="20dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#id/comments_list"
android:layout_marginBottom="10dp"
android:id="#+id/toggle_content"
android:layout_alignParentBottom="true">
<TextView
android:id="#+id/like_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:text="1000"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/like_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_like_button_selctor" />
<TextView
android:id="#+id/comment_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="7dp"
android:text="100"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/comment_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_comment_button_selector" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Try this..
<LinearLayout
android:id="#+id/updatedetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:orientation="vertical"
android:background="#drawable/oneeventbkg" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/Top_half_layout">
// Your Codes
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/bottom_half_layout">
// Your Codes
</LinearLayout>
</LinearLayout>
EDIT
<LinearLayout
android:id="#+id/updatedetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:orientation="vertical"
android:background="#drawable/oneeventbkg" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/Top_half_layout">
// Your Codes
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/bottom_half_layout">
// Your Codes
</RelativeLayout>
</LinearLayout>
// Try this way,hope this will help you to solve your problem...
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/updatedetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:background="#drawable/oneeventbkg" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/Top_half_layout"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/update_sn_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="10dp"
android:layout_marginTop="2dp" />
<TextView
android:id="#+id/update_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:textColor="#android:color/white"
android:layout_gravity="right"
android:textSize="14sp" />
</LinearLayout>
<ImageView
android:id="#+id/update_message_pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp" />
<TextView
android:id="#+id/update_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:maxHeight="400dp"
android:scrollbars="vertical"
android:textColor="#android:color/white"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/bottom_half_layout"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp"
android:id="#+id/toggle_after"
android:visibility="invisible">
<TextView
android:id="#+id/toggle_like_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:text="1000"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/toggle_like_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_like_button_selctor" />
<TextView
android:id="#+id/toggle_comment_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="7dp"
android:text="100"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/toggle_comment_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_comment_button_selector" />
</LinearLayout>
<ListView
android:id="#+id/likes_list"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:padding="20dp" />
<ListView
android:id="#+id/comments_list"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:padding="20dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp"
android:id="#+id/toggle_content">
<TextView
android:id="#+id/like_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:text="1000"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/like_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_like_button_selctor" />
<TextView
android:id="#+id/comment_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="7dp"
android:text="100"
android:background="#android:color/transparent"
android:textColor="#android:color/white"
android:textSize="14sp" />
<ImageButton
android:id="#+id/comment_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:background="#android:color/transparent"
android:src="#drawable/xml_comment_button_selector" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>