<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
>
<TextView
android:id="#+id/nameText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:fontFamily="sans-serif-medium"
android:letterSpacing="-0.03"
android:text="Ajay Kulkarni"
android:textColor="#3e4360"
android:textSize="16sp"
android:textStyle="normal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/nameText"
android:fontFamily="sans-serif"
android:letterSpacing="-0.03"
android:text="Co-Founder"
android:gravity="right"
android:textColor="#color/bluey_grey_three"
android:textSize="12sp"
android:textStyle="normal"/>
<com.kdcos.contsync.utilities.RoundedImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginEnd="32dp"
android:layout_toStartOf="#+id/imageView3"
android:background="#drawable/ic_success_illustration" />
<com.kdcos.contsync.utilities.RoundedImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_alignParentEnd="true"
android:layout_marginEnd="29dp"
android:background="#drawable/ic_cards_active"
android:id="#+id/imageView3" />
<com.kdcos.contsync.utilities.RoundedImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_alignParentEnd="true"
android:layout_marginEnd="29dp"
android:layout_toLeftOf="#+id/imageView3"
android:background="#drawable/ic_cards_active"
android:id="#+id/imageView4" />
</RelativeLayout>
this is my xml i want set all 2 textview 2 imageview right of relative layout in android . my expected screen is like below please suggest me how i will set textview and imageview in right top in relative layout .
using given code i am able keep one imageview right side i have keep both textview right and one imageview also .
Use this code. Cheers.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp">
<TextView
android:id="#+id/nameText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toStartOf="#id/imageView3"
android:ems="10"
android:fontFamily="sans-serif-medium"
android:gravity="end"
android:letterSpacing="-0.03"
android:text="Ajay Kulkarni"
android:textColor="#3e4360"
android:textSize="16sp"
android:textStyle="normal" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/nameText"
android:fontFamily="sans-serif"
android:gravity="end"
android:layout_toStartOf="#id/imageView3"
android:letterSpacing="-0.03"
android:text="Co-Founder"
android:textSize="12sp"
android:textStyle="normal" />
<com.kdcos.contsync.utilities.RoundedImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginEnd="32dp"
android:layout_toStartOf="#+id/imageView3"
android:background="#drawable/ic_success_illustration" />
<com.kdcos.contsync.utilities.RoundedImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_alignParentEnd="true"
android:layout_marginEnd="29dp"
android:background="#drawable/ic_cards_active"
android:id="#+id/imageView3" />
<com.kdcos.contsync.utilities.RoundedImageView
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_alignParentEnd="true"
android:layout_marginEnd="29dp"
android:layout_toLeftOf="#+id/imageView3"
android:background="#drawable/ic_cards_active"
android:id="#+id/imageView4" />
</RelativeLayout>
Try this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:layout_weight=".1">
<TextView
android:id="#+id/nameText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:fontFamily="sans-serif-medium"
android:letterSpacing="-0.03"
android:text="Ajay Kulkarni"
android:textColor="#3e4360"
android:gravity="right"
android:textSize="16sp"
android:textStyle="normal"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/nameText"
android:fontFamily="sans-serif"
android:letterSpacing="-0.03"
android:text="Co-Founder"
android:gravity="right"
android:textColor="#color/cardview_dark_background"
android:textSize="12sp"
android:textStyle="normal"/>
</RelativeLayout>
<ImageView
android:layout_width="0dp"
android:layout_height="100dp"
android:scaleType="fitXY"
android:id="#+id/imgone"
android:tint="#color/colorPrimary"
android:src="#mipmap/ic_camera_white_48dp"
android:layout_weight=".1"/>
<ImageView
android:layout_width="0dp"
android:layout_height="100dp"
android:tint="#color/colorPrimary"
android:id="#+id/imagetow"
android:scaleType="fitXY"
android:src="#mipmap/ic_camera_white_48dp"
android:layout_weight=".1"/>
</LinearLayout>
</RelativeLayout>
Output
Related
Is there a way to do this in android studio? I want to achieve that when you scroll down the header will overlap above and under is the scrollview part. What I've got is it scrolls over the header. In android studio
This is what Im trying to achieve that was made in figma
Default
When you scroll
So far this is what my code looks like
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".Fragment.RecordFragment"
android:orientation="vertical">
<View
android:layout_width="369dp"
android:layout_height="71dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="13dp"
android:layout_alignParentTop="true"
android:layout_marginTop="14dp"
android:background="#drawable/ic_header"/>
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="25dp"
android:layout_marginTop="25dp"
android:layout_marginEnd="25dp"
android:layout_marginBottom="25dp"
android:text="Record"
android:textAlignment="center"
android:textColor="#color/white"
android:textSize="35sp" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="100dp">
<TextView
android:id="#+id/txtDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="128dp"
android:text="Date for today"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="50sp" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<View
android:layout_width="316dp"
android:layout_height="201dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:background="#drawable/sec_bp" />
<EditText
android:layout_width="250dp"
android:layout_height="30dp"
android:layout_marginLeft="30dp"
android:layout_marginTop="70dp"
android:background="#drawable/rounded_corner"
android:gravity="center"
android:hint="SBP" />
<EditText
android:layout_width="250dp"
android:layout_height="30dp"
android:layout_marginLeft="30dp"
android:layout_marginTop="120dp"
android:background="#drawable/rounded_corner"
android:gravity="center"
android:hint="DBP" />
<EditText
android:layout_width="250dp"
android:layout_height="30dp"
android:layout_marginLeft="30dp"
android:layout_marginTop="170dp"
android:background="#drawable/rounded_corner"
android:gravity="center"
android:hint="BPM" />
<Button
android:layout_width="70dp"
android:layout_height="30dp"
android:layout_marginLeft="120dp"
android:layout_marginTop="210dp"
android:background="#drawable/rounded_corner"
android:gravity="center"
android:text="save" />
</RelativeLayout>
<View
android:layout_width="316dp"
android:layout_height="117dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:background="#drawable/sec_temp" />
<View
android:layout_width="316dp"
android:layout_height="117dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="50dp"
android:background="#drawable/sec_temp" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
Try adding elevation inside your header view. like this :
<View
android:layout_width="369dp"
android:layout_height="71dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="13dp"
android:layout_alignParentTop="true"
android:layout_marginTop="14dp"
android:background="#drawable/ic_header"/
android:elevation="1dp">
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="25dp"
android:layout_marginTop="25dp"
android:layout_marginEnd="25dp"
android:layout_marginBottom="25dp"
android:text="Record"
android:textAlignment="center"
android:textColor="#color/white"
android:textSize="35sp"
android:elevation="2dp"/>
I set the View elevation 1dp and the TextView 2dp so that the text can still in front of the View.
I am trying to use horizontal scrollview inside a scroll view. My parent scroll isn't scrolling smoothly. Although my child scroll is scrolling smoothly, I want to achieve smooth scrolling of parent scroll. I have tried every method, I have in my mind setting HardwareAccelerated to false worked but it removed elevation from my views.
Main 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"
android:background="#ECEFF1"
android:clipToPadding="false">
<RelativeLayout
android:layout_width="250dp"
android:layout_height="90dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="75dp"
android:layout_marginTop="100dp"
android:background="#drawable/round_corners"
android:clipToPadding="false"
android:elevation="5dp"
android:translationZ="5dp"
tools:layout_editor_absoluteX="42dp"
tools:layout_editor_absoluteY="121dp">
<ImageView
android:id="#+id/enquiry"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentEnd="true"
android:layout_alignTop="#+id/visa"
android:layout_marginEnd="35dp"
app:srcCompat="#drawable/phone" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignTop="#+id/textView2"
android:layout_marginEnd="20dp"
android:text="Enquiry"
android:textColor="#color/navigationBarColor"
android:textSize="15sp" />
<ImageView
android:id="#+id/visa"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignTop="#+id/holidays"
android:layout_centerHorizontal="true"
app:srcCompat="#drawable/globe" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/textView3"
android:layout_centerHorizontal="true"
android:text="Visa"
android:textColor="#android:color/background_dark"
android:textSize="15sp" />
<ImageView
android:id="#+id/holidays"
android:layout_width="25dp"
android:layout_height="32dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="35dp"
android:layout_marginTop="18dp"
app:srcCompat="#drawable/plane" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="14dp"
android:layout_marginStart="20dp"
android:text="Holidays"
android:textColor="#android:color/background_dark" />
</RelativeLayout>
<include
android:id="#+id/toolbar"
layout="#layout/app_bar" />
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="false"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="#color/colorPrimary"
android:fontFamily="serif"
android:text="Call"
android:textColor="#color/textColorPrimary"
android:textSize="20sp" />
<ScrollView
android:id="#+id/parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="200dp"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="30dp"
android:orientation="vertical">
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="0dp"
android:layout_marginLeft="25dp"
android:layout_marginTop="50dp"
android:text="Pilgrimage"
android:textColor="#android:color/background_dark"
android:textSize="25sp"
android:textStyle="bold" />
<android.support.v7.widget.CardView
android:id="#+id/pilg"
class="com.example.admin.myapplication.Pilgrimage"
android:layout_width="320dp"
android:layout_height="240dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="25dp"
android:layout_marginTop="20dp"
android:background="#drawable/round_corners"
android:elevation="5dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="#drawable/hu" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:layout_marginTop="155dp"
android:fontFamily="serif"
android:text="Hajj And Umrah"
android:textColor="#color/navigationBarColor"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="190dp"
android:text="Ramzan Umrah"
android:textColor="#color/colorPrimaryDark"
android:textSize="12sp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="210dp"
android:layout_marginTop="190dp"
android:text="29 Days/30 Nights"
android:textColor="#color/colorPrimaryDark"
android:textSize="12sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="205dp"
android:text="Starts From Rs.65,000/-"
android:textColor="#color/colorPrimaryDark"
android:textSize="12sp" />
</android.support.v7.widget.CardView>
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginTop="25dp"
android:text="Holiday Packages"
android:textColor="#color/navigationBarColor"
android:textSize="25sp"
android:textStyle="bold" />
<HorizontalScrollView
android:id="#+id/child"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<RelativeLayout
android:id="#+id/international"
class="com.example.admin.myapplication.International"
android:layout_width="200dp"
android:layout_height="225dp"
android:layout_marginBottom="30dp"
android:layout_marginLeft="25dp"
android:layout_marginTop="20dp"
android:background="#mipmap/ll"
android:elevation="5dp"
android:padding="-25dp">
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="11dp"
android:fontFamily="serif"
android:text="International"
android:textColor="#color/textColorPrimary"
android:textSize="20sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/dom1"
android:layout_width="200dp"
android:layout_height="225dp"
android:layout_marginBottom="30dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="25dp"
android:layout_marginTop="20dp"
android:background="#mipmap/rajasthan"
android:elevation="5dp">
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="12dp"
android:fontFamily="serif"
android:text="Domestic"
android:textColor="#color/textColorPrimary"
android:textSize="20sp" />
</RelativeLayout>
</LinearLayout>
</HorizontalScrollView>
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="30dp"
android:layout_marginLeft="25dp"
android:layout_marginTop="25dp"
android:text="Social"
android:textColor="#color/navigationBarColor"
android:textSize="25sp" />
<LinearLayout
android:layout_width="335dp"
android:layout_height="50dp"
android:layout_marginBottom="100dp"
android:layout_marginLeft="25dp"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
</ScrollView>
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="14dp"
android:fontFamily="serif"
android:text="Al Shariq Enterprises"
android:textColor="#color/textColorPrimary"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
Try this NestedScrollView like this :-
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="200dp">
<android.support.v4.widget.NestedScrollView
android:id="#+id/parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="30dp"
android:orientation="vertical">
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="0dp"
android:layout_marginLeft="25dp"
android:layout_marginTop="50dp"
android:text="Pilgrimage"
android:textColor="#android:color/background_dark"
android:textSize="25sp"
android:textStyle="bold" />
<android.support.v7.widget.CardView
android:id="#+id/pilg"
class="com.example.admin.myapplication.Pilgrimage"
android:layout_width="320dp"
android:layout_height="240dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="25dp"
android:layout_marginTop="20dp"
android:background="#drawable/round_corners"
android:elevation="5dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="#drawable/hu" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:layout_marginTop="155dp"
android:fontFamily="serif"
android:text="Hajj And Umrah"
android:textColor="#color/navigationBarColor"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="190dp"
android:text="Ramzan Umrah"
android:textColor="#color/colorPrimaryDark"
android:textSize="12sp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="210dp"
android:layout_marginTop="190dp"
android:text="29 Days/30 Nights"
android:textColor="#color/colorPrimaryDark"
android:textSize="12sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="205dp"
android:text="Starts From Rs.65,000/-"
android:textColor="#color/colorPrimaryDark"
android:textSize="12sp" />
</android.support.v7.widget.CardView>
<TextView
android:id="#+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginTop="25dp"
android:text="Holiday Packages"
android:textColor="#color/navigationBarColor"
android:textSize="25sp"
android:textStyle="bold" />
<HorizontalScrollView
android:id="#+id/child"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<RelativeLayout
android:id="#+id/international"
class="com.example.admin.myapplication.International"
android:layout_width="200dp"
android:layout_height="225dp"
android:layout_marginBottom="30dp"
android:layout_marginLeft="25dp"
android:layout_marginTop="20dp"
android:background="#mipmap/ll"
android:elevation="5dp"
android:padding="-25dp">
<TextView
android:id="#+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="11dp"
android:fontFamily="serif"
android:text="International"
android:textColor="#color/textColorPrimary"
android:textSize="20sp" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/dom1"
android:layout_width="200dp"
android:layout_height="225dp"
android:layout_marginBottom="30dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="25dp"
android:layout_marginTop="20dp"
android:background="#mipmap/rajasthan"
android:elevation="5dp">
<TextView
android:id="#+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="12dp"
android:fontFamily="serif"
android:text="Domestic"
android:textColor="#color/textColorPrimary"
android:textSize="20sp" />
</RelativeLayout>
</LinearLayout>
</HorizontalScrollView>
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="30dp"
android:layout_marginLeft="25dp"
android:layout_marginTop="25dp"
android:text="Social"
android:textColor="#color/navigationBarColor"
android:textSize="25sp" />
<LinearLayout
android:layout_width="335dp"
android:layout_height="50dp"
android:layout_marginBottom="100dp"
android:layout_marginLeft="25dp"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
For basic details you can check this link.
I think that this happens because both of your ScrollViews reacts to scrolling so it seems to you that it lags, but it actually don't, its just vertical ScrollView interrupting horizontal ScrollView.
It is not recommended using ScrollView inside another ScrollView. Instead use NestedScrollView as in this answer.
I'm trying to create a layout for a user leader-board but I don't know how to make every "row" equal in proportion.
Here's the list of users:
And this is the code of the child layout (that populates a recyclerview):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/topUsersLeaderboardItem_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="12"
android:orientation="horizontal"
android:paddingBottom="#dimen/margin_extra_small"
android:paddingTop="#dimen/margin_extra_small">
<TextView
android:id="#+id/topUsersLeaderboardItem_position"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:paddingStart="#dimen/margin_small"
android:textColor="#color/colorBlack"
android:layout_weight="2"
android:layout_gravity="center_vertical"
android:textSize="#dimen/font_size_small"/>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="8">
<RelativeLayout
android:id="#+id/topUsersLeaderboardItem_layoutPicUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<ImageView
android:id="#+id/topUsersLeaderboardItem_userIcon"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerHorizontal="true"
android:src="#drawable/circular_profile"
app:srcCompat="#drawable/circular_profile" />
<TextView
android:id="#+id/topUsersLeaderboardItem_userInitial"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:gravity="center_vertical|center_horizontal|center"
android:text="U"
android:textSize="#dimen/font_size_medium"/>
</RelativeLayout>
<TextView
android:id="#+id/topUsersLeaderboardItem_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_centerVertical="true"
android:gravity="center_vertical|center_horizontal"
android:text="uername"
android:textColor="#color/colorBlack"
android:layout_marginStart="8dp"
android:layout_toEndOf="#+id/topUsersLeaderboardItem_layoutPicUser"
android:textSize="#dimen/font_size_small"/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/topUsersLeaderboardItem_scoreLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2"
android:gravity="end">
<TextView
android:id="#+id/topUsersLeaderboardItem_score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:text="150"
android:textSize="#dimen/font_size_small"
android:textColor="#color/colorBlack" />
<ImageView
android:id="#+id/topUsersLeaderboardItem_starImage"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentEnd="false"
android:layout_centerVertical="true"
android:layout_marginEnd="#dimen/margin_small"
android:layout_toEndOf="#+id/topUsersLeaderboardItem_score"
android:src="#drawable/ic_star_yellow_24dp"
app:srcCompat="#drawable/ic_star_yellow_24dp" />
</RelativeLayout>
As you can see from the picture, the space taken by the numbers on the left increases when I would like it to be fixed. Is there a way to make this sort of "table layout"? Thanks everybody!
Actually, it is because of android:layout_width="wrap_content"
of first TextView, give it some predefined value like android:layout_width="10dp". Don't forget to remove gravity from TextView.
please use this
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/topUsersLeaderboardItem_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="12"
android:orientation="horizontal"
android:paddingBottom="#dimen/margin_extra_small"
android:paddingTop="#dimen/margin_extra_small">
<TextView
android:id="#+id/topUsersLeaderboardItem_position"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="0"
android:paddingStart="#dimen/margin_small"
android:textColor="#color/colorBlack"
android:layout_weight="2"
android:layout_gravity="center_vertical"
android:textSize="#dimen/font_size_small"/>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="8">
<RelativeLayout
android:id="#+id/topUsersLeaderboardItem_layoutPicUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<ImageView
android:id="#+id/topUsersLeaderboardItem_userIcon"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerHorizontal="true"
android:src="#drawable/circular_profile"
app:srcCompat="#drawable/circular_profile" />
<TextView
android:id="#+id/topUsersLeaderboardItem_userInitial"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:gravity="center_vertical|center_horizontal|center"
android:text="U"
android:textSize="#dimen/font_size_medium"/>
</RelativeLayout>
<TextView
android:id="#+id/topUsersLeaderboardItem_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_centerVertical="true"
android:gravity="center_vertical|center_horizontal"
android:text="uername"
android:textColor="#color/colorBlack"
android:layout_marginStart="8dp"
android:layout_toEndOf="#+id/topUsersLeaderboardItem_layoutPicUser"
android:textSize="#dimen/font_size_small"/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/topUsersLeaderboardItem_scoreLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="2">
<TextView
android:id="#+id/topUsersLeaderboardItem_score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:text="150"
android:textSize="#dimen/font_size_small"
android:textColor="#color/colorBlack" />
<ImageView
android:id="#+id/topUsersLeaderboardItem_starImage"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentEnd="false"
android:layout_centerVertical="true"
android:layout_marginEnd="#dimen/margin_small"
android:layout_toEndOf="#+id/topUsersLeaderboardItem_score"
android:src="#drawable/ic_star_yellow_24dp"
app:srcCompat="#drawable/ic_star_yellow_24dp" />
</RelativeLayout>
I have layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/text_color"
android:minHeight="285dp"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/credit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="-30dp">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="#drawable/bonus_badge"/>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="6dp"
android:text="Get"
android:textColor="#color/black"
android:textSize="12sp"/>
<!-- don't change this layout view order -->
<TextView
android:id="#+id/amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="18dp"
android:text="$1xxx"
android:textColor="#color/black"
android:textSize="14sp"
android:textStyle="bold"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<ImageView
android:id="#+id/image"
android:layout_width="162dp"
android:layout_height="112dp"
android:adjustViewBounds="true"
android:src="#drawable/test_image"/>
<ImageView
android:id="#+id/topFlag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="#drawable/sold_out"
android:visibility="gone"/>
<ImageView
android:id="#+id/waitListFlag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="#drawable/join_wait_list"
android:visibility="gone"/>
</RelativeLayout>
<TextView
android:id="#+id/options"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="Options"
android:textColor="#color/unactive_color"
android:textSize="14sp"/>
<TextView
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:ellipsize="end"
android:maxHeight="80dp"
android:maxLines="3"
android:minHeight="40dp"
android:minLines="3"
android:text="name"
android:textColor="#color/dark_cyan"
android:textSize="16sp"/>
<TextView
android:id="#+id/oldPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="old price"
android:textColor="#color/unactive_color"
android:textSize="14sp"/>
<TextView
android:id="#+id/newPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="new price"
android:textColor="#color/price_black"
android:textSize="22sp"/>
<TextView
android:id="#+id/Save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="save"
android:textColor="#color/unactive_color"
android:textSize="14sp"/>
<View
android:id="#+id/view1"
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_marginTop="10dp"
android:background="#color/divider_color_product"/>
</LinearLayout>
And Actual result is:
But I need something like that:
The problem is with the yellow-badge android:id="#+id/credit".
I need to have it above the image which the space before.
I'm trying to set programmatically bringToFront(); but nothing happens.
Also I'm trying to play with layout_below layout_above attributes.
Where is the problem ? Anyway, thank you!
It seems that the second RelativeLayout is the big image, and the first is the tag. So I modify the xml below, hope this is what you want :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/text_color"
android:minHeight="285dp"
android:orientation="vertical">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp">
<ImageView
android:id="#+id/image"
android:layout_width="162dp"
android:layout_height="112dp"
android:adjustViewBounds="true"
android:src="#drawable/test_image" />
<ImageView
android:id="#+id/topFlag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:background="#drawable/sold_out"
android:visibility="gone" />
<ImageView
android:id="#+id/waitListFlag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="#drawable/join_wait_list"
android:visibility="gone" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/credit"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="#drawable/bonus_badge" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="6dp"
android:text="Get"
android:textColor="#color/black"
android:textSize="12sp" />
<!-- don't change this layout view order -->
<TextView
android:id="#+id/amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="18dp"
android:text="$1xxx"
android:textColor="#color/black"
android:textSize="14sp"
android:textStyle="bold" />
</RelativeLayout>
</FrameLayout>
<TextView
android:id="#+id/options"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="Options"
android:textColor="#color/unactive_color"
android:textSize="14sp" />
<TextView
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:ellipsize="end"
android:maxHeight="80dp"
android:maxLines="3"
android:minHeight="40dp"
android:minLines="3"
android:text="name"
android:textColor="#color/dark_cyan"
android:textSize="16sp" />
<TextView
android:id="#+id/oldPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="old price"
android:textColor="#color/unactive_color"
android:textSize="14sp" />
<TextView
android:id="#+id/newPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="new price"
android:textColor="#color/price_black"
android:textSize="22sp" />
<TextView
android:id="#+id/Save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:text="save"
android:textColor="#color/unactive_color"
android:textSize="14sp" />
<View
android:id="#+id/view1"
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_marginTop="10dp"
android:background="#color/divider_color_product" />
</LinearLayout>
create you parent relativelayout , then and what you want inside it , to get overlay effect , you should know that the blow layout appear in the above of the pervious layout
--relativelayout
|
---------ImageView
|
---------Relativelayout (let it alignParentTop)
|
------ImageView
|
------TextView(center in parent)
In my app am using customized listed view with text view and Buttons.The screen size is 4.65" 720p(720X1280 : xhdpi),device take this resolution from layout-large folder.when i run it on device.the list view item and header display not fit to the screen like image shown below,some empty space in the end of row.Its not able to fit to the screen.Can any one know please help me to solve this issue.
Header XML Coding
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/search_lay"
android:layout_marginTop="1dp"
android:background="#e8e8e8" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="32dp"
android:text="Item(s)"
android:textColor="#dd1713"
android:textSize="13sp" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="48dp"
android:layout_toRightOf="#+id/textView1"
android:text="Price(Rs.)"
android:textColor="#dd1713"
android:textSize="13sp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="18dp"
android:layout_toRightOf="#+id/textView3"
android:text="Qty"
android:textColor="#dd1713"
android:textSize="13sp" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="28dp"
android:layout_toRightOf="#+id/textView2"
android:text="Total(Rs.)"
android:textColor="#dd1713"
android:textSize="13sp" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="3dp"
android:text="Fav"
android:textColor="#dd1713"
android:textSize="13sp" />
</RelativeLayout>
Customized List-view XML Coding
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#ffffff" >
<TextView
android:id="#+id/orderlist_product_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:visibility="gone" />
<RelativeLayout
android:layout_width="30dp"
android:layout_height="match_parent" >
<ImageView
android:id="#+id/fav_img"
android:layout_width="30dp"
android:layout_height="30dp"
android:background="#drawable/fav_order_list_btn" />
<Button
android:id="#+id/special_inst_btn"
android:layout_width="25dp"
android:layout_height="18dp"
android:layout_below="#+id/fav_img"
android:layout_centerHorizontal="true"
android:background="#drawable/special_inst_btn_in_orderlist"
android:gravity="center"
android:text="+"
android:textColor="#ffffff"
android:textSize="14sp" />
</RelativeLayout>
<TextView
android:id="#+id/order_list_itemname"
android:layout_width="95dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="1dp"
android:text="Item name"
android:textColor="#000000"
android:textSize="12sp"
android:typeface="serif" />
<RelativeLayout
android:layout_width="34dp"
android:layout_height="match_parent"
android:layout_marginLeft="2dp" >
<TextView
android:id="#+id/orderlist_offer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="4dp"
android:gravity="center"
android:textColor="#298616"
android:textSize="10sp" />
<TextView
android:id="#+id/orderlist_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:gravity="right"
android:text="200.00"
android:textColor="#000000"
android:textSize="10sp"
android:typeface="serif" />
</RelativeLayout>
<Button
android:id="#+id/orderlist_minus"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginTop="1dp"
android:background="#drawable/sub_button_click" />
<EditText
android:id="#+id/order_list_quantity"
android:layout_width="27dp"
android:layout_height="25dp"
android:layout_marginTop="13dp"
android:background="#drawable/et_bg"
android:ems="10"
android:focusable="false"
android:focusableInTouchMode="false"
android:gravity="center"
android:inputType="number"
android:textColor="#000000"
android:textSize="12dp"
android:typeface="serif" >
<requestFocus />
</EditText>
<Button
android:id="#+id/orderlist_plus"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center"
android:layout_marginTop="1dp"
android:background="#drawable/plus_btn_click" />
<TextView
android:id="#+id/orderlist_total"
android:layout_width="43dp"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:layout_marginTop="13dp"
android:gravity="right"
android:text="1000.00"
android:textColor="#000000"
android:textSize="11sp"
android:typeface="serif" />
<Button
android:id="#+id/orderlist_delete"
android:layout_width="23dp"
android:layout_height="23dp"
android:layout_gravity="center"
android:layout_marginLeft="3dp"
android:layout_marginTop="1dp"
android:background="#drawable/order_list_delete" />
</LinearLayout>
</RelativeLayout>
i m giving u a demo.this layout will work on all size layout,this will definitely help u #Yugesh.
weight works percentage-wise on all screen.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".30"
android:gravity="center_horizontal" >
<ImageView
android:id="#+id/image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/image1"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".30"
android:text="30%" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".20"
android:text="20%" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".20"
android:text="20%" />
</LinearLayout>
</RelativeLayout>
further more,if there is any query,then please ask...