I am trying to create a scrollable list with ratingbars and textviews.
However I am unable to get them to align correctly. I would like even spacing between all textviews and rating bars..
I have tried to use the layout_below but this does not produce what I would like, I have also tried dragging, but this also does not create the wanted effect.
Any help would be appreciated :)
<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="#color/colorPrimaryDark"
tools:context="uk.co.neverendingsport.neverendingsport.LoginActivity">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Continue"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="13dp"
android:id="#+id/button" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select Sports"
android:textSize="30sp"
android:textStyle="bold"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="#+id/textView4"
android:layout_alignParentStart="true">
<TextView
android:id="#+id/footballTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Football"
android:textSize="30sp"
android:layout_above="#+id/cyclingRatingBar"
android:layout_alignParentStart="true" />
<RatingBar
android:id="#+id/footballRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/cyclingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cycling"
android:textSize="30sp"
android:layout_above="#+id/badmintonTextView"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp" />
<RatingBar
android:id="#+id/cyclingRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/footballRatingBar"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/badmintonTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Badminton"
android:textSize="30sp"
android:layout_below="#+id/cyclingRatingBar"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/badmintonRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/runningTextView"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/runningTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Running"
android:textSize="30sp"
android:layout_below="#+id/badmintonTextView"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/runningRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/badmintonRatingBar"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/swimmingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Swimming"
android:textSize="30sp"
android:layout_below="#+id/runningTextView"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/swimmingRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/runningRatingBar"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/golfTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Golf"
android:textSize="30sp"
android:layout_below="#+id/swimmingTextView"
android:layout_alignParentStart="true"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/golfRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/swimmingRatingBar"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</RelativeLayout>
Image of current layout
Here is the answer that works fine for me
<?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">
<TextView
android:id="#+id/textView2"
style="#style/Base.TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Select Sports" />
<TextView
android:id="#+id/textView6"
style="#style/Base.TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/ratingBar"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="17dp"
android:layout_toLeftOf="#+id/ratingBar"
android:layout_toStartOf="#+id/ratingBar"
android:text="Football" />
<RatingBar
android:id="#+id/ratingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/textView2" />
<RatingBar
android:id="#+id/ratingBar2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/ratingBar" />
<RatingBar
android:id="#+id/ratingBar3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/ratingBar2"
android:layout_alignStart="#+id/ratingBar2"
android:layout_below="#+id/ratingBar2" />
<RatingBar
android:id="#+id/ratingBar4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/ratingBar3"
android:layout_alignStart="#+id/ratingBar3"
android:layout_below="#+id/ratingBar3" />
<TextView
android:id="#+id/textView7"
style="#style/Base.TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/ratingBar3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="17dp"
android:layout_toLeftOf="#+id/textView2"
android:text="Cycling" />
<TextView
android:id="#+id/textView8"
style="#style/Base.TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/ratingBar4"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="14dp"
android:layout_toLeftOf="#+id/ratingBar3"
android:text="Badminton" />
<TextView
android:id="#+id/textView9"
style="#style/Base.TextAppearance.AppCompat.Large"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/ratingBar4"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="16dp"
android:layout_toLeftOf="#+id/ratingBar4"
android:text="Running" />
</RelativeLayout>]
final output
First of all you need to add rating bar to parent layout and later textview to the parent layout
Try this
<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="#color/colorPrimaryDark"
tools:context="uk.co.neverendingsport.neverendingsport.LoginActivity">
<Button
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="13dp"
android:text="Continue" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Select Sports"
android:textSize="30sp"
android:textStyle="bold" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_below="#+id/textView4">
<RelativeLayout
android:id="#+id/relativeFootball"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/footballTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Football"
android:textSize="30sp" />
<RatingBar
android:id="#+id/footballRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeCycle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeFootball">
<TextView
android:id="#+id/cyclingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Cycling"
android:textSize="30sp" />
<RatingBar
android:id="#+id/cyclingRatingBar"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeBadminton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeCycle">
<TextView
android:id="#+id/badmintonTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Badminton"
android:textSize="30sp" />
<RatingBar
android:id="#+id/badmintonRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeRunning"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeBadminton">
<TextView
android:id="#+id/runningTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Running"
android:textSize="30sp" />
<RatingBar
android:id="#+id/runningRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeSwimming"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeRunning">
<TextView
android:id="#+id/swimmingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:text="Swimming"
android:textSize="30sp" />
<RatingBar
android:id="#+id/swimmingRatingBar"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeGolf"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeSwimming">
<TextView
android:id="#+id/golfTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="Golf"
android:textSize="30sp" />
<RatingBar
android:id="#+id/golfRatingBar"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimaryDark"
>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Continue"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="13dp"
android:id="#+id/button" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select Sports"
android:textSize="28sp"
android:textStyle="bold"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView4"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="#+id/footballTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Football"
android:textSize="28sp"
android:layout_weight="1"
android:layout_above="#+id/cyclingRatingBar"
/>
<RatingBar
android:id="#+id/footballRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="#+id/cyclingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cycling"
android:textSize="28sp"
android:layout_weight="1"
android:layout_above="#+id/badmintonTextView"
android:layout_marginBottom="10dp" />
<RatingBar
android:id="#+id/cyclingRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/footballRatingBar"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="#+id/badmintonTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Badminton"
android:textSize="28sp"
android:layout_below="#+id/cyclingRatingBar"
android:layout_weight="1"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/badmintonRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/runningTextView"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="#+id/runningTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Running"
android:textSize="28sp"
android:layout_weight="1"
android:layout_below="#+id/badmintonTextView"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/runningRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/badmintonRatingBar"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="#+id/swimmingTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Swimming"
android:textSize="28sp"
android:layout_weight="1"
android:layout_below="#+id/runningTextView"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/swimmingRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/runningRatingBar"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="#+id/golfTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Golf"
android:textSize="28sp"
android:layout_weight="1"
android:layout_below="#+id/swimmingTextView"
android:layout_marginBottom="10dp"/>
<RatingBar
android:id="#+id/golfRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/swimmingRatingBar"
>
</RatingBar>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
Related
<?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="#color/colorPrimaryDark"
tools:context="com.example.fake9.tendee.SettingsActivity">
<TextView
android:id="#+id/settings_display_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="119dp"
android:text="Name"
android:textColor="#android:color/white"
android:textSize="30sp" />
<TextView
android:id="#+id/settings_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/settings_display_name"
android:layout_centerHorizontal="true"
android:layout_marginTop="61dp"
android:text="Email"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/settings_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/settings_display_name"
android:layout_below="#+id/settings_email"
android:layout_marginTop="62dp"
android:layout_centerHorizontal="true"
android:text="Decription"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/settings_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/settings_description"
android:layout_centerHorizontal="true"
android:layout_marginTop="80dp"
android:text="Address"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/settings_edit_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignBottom="#+id/settings_description"
android:layout_marginStart="37dp"
android:layout_toEndOf="#+id/settings_description"
android:drawableStart="#drawable/ic_mode_edit_white_18dp" />
<TextView
android:id="#+id/settings_edit_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignBottom="#+id/settings_address"
android:layout_alignStart="#+id/settings_edit_description"
android:drawableStart="#drawable/ic_mode_edit_white_18dp" />
<Button
android:id="#+id/EditPassBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="31dp"
android:backgroundTint="#color/colorAccent"
android:text="Change Password"
android:textColor="#android:color/black" />
</RelativeLayout>
How do I center the text in the TextView in the center? The others are working but not the center one. I have added the same tags I have added for the other textviews. I would like all the text here to be centered.
The pictures to the right of the text are also textviews. I'm not sure what more I can do as all the tags are the same.
Try using this:
<?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="#color/colorPrimaryDark"
tools:context="com.example.fake9.tendee.SettingsActivity">
<TextView
android:id="#+id/settings_display_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:gravity="center"
android:layout_marginTop="119dp"
android:text="Name"
android:textColor="#android:color/white"
android:textSize="30sp" />
<TextView
android:id="#+id/settings_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/settings_display_name"
android:layout_centerHorizontal="true"
android:gravity="center"
android:layout_marginTop="61dp"
android:text="Email"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/settings_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/settings_display_name"
android:layout_below="#+id/settings_email"
android:gravity="center"
android:layout_marginTop="62dp"
android:drawableEnd="#drawable/ic_mode_edit_white_18dp"
android:drawableRight="#drawable/ic_mode_edit_white_18dp"
android:layout_centerHorizontal="true"
android:text="Decription"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/settings_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/settings_description"
android:layout_centerHorizontal="true"
android:layout_marginTop="80dp"
android:gravity="center"
android:drawableEnd="#drawable/ic_mode_edit_white_18dp"
android:drawableRight="#drawable/ic_mode_edit_white_18dp"
android:text="Address"
android:textColor="#android:color/white"
android:textSize="18sp"
/>
<Button
android:id="#+id/EditPassBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="31dp"
android:backgroundTint="#color/colorAccent"
android:text="Change Password"
android:textColor="#android:color/black" />
</RelativeLayout>
Kindly use android:layout_gravity="center_horizontal"
<?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="#color/colorPrimaryDark"
tools:context="com.example.fake9.tendee.SettingsActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="10dp">
<TextView
android:id="#+id/settings_display_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="119dp"
android:text="Name"
android:textColor="#android:color/white"
android:textSize="30sp" />
<TextView
android:id="#+id/settings_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/settings_display_name"
android:layout_centerHorizontal="true"
android:layout_marginTop="61dp"
android:text="Email"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/settings_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/settings_display_name"
android:layout_below="#+id/settings_email"
android:layout_marginTop="62dp"
android:layout_centerHorizontal="true"
android:text="Decription"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/settings_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/settings_description"
android:layout_centerHorizontal="true"
android:layout_marginTop="80dp"
android:text="Address"
android:textColor="#android:color/white"
android:textSize="18sp" />
<TextView
android:id="#+id/settings_edit_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignBottom="#+id/settings_description"
android:layout_marginStart="37dp"
android:layout_toEndOf="#+id/settings_description"
android:drawableStart="#drawable/ic_mode_edit_white_18dp" />
<TextView
android:id="#+id/settings_edit_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignBottom="#+id/settings_address"
android:layout_alignStart="#+id/settings_edit_description"
android:drawableStart="#drawable/ic_mode_edit_white_18dp" />
<Button
android:id="#+id/EditPassBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="31dp"
android:backgroundTint="#color/colorAccent"
android:text="Change Password"
android:textColor="#android:color/black" />
I have a three section relative layout for a login page.
The first section at the top of the page is 1 Imageview and 2 Textviews.
The second section is 6 RelativeLayouts containing 1 ImageView to the left and 1 TextView to the right.
The third section is a Button
The first four icons are ok on any device. The 5th and 6th are both getting resized or not showing up.
I would like to see all 6 but if 1 can't fit dont add it. How can I do this in a proper way.
Thanks - P.S Code is below
<?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"
android:background="#drawable/newd_login_overlay"
android:orientation="vertical" >
<LinearLayout android:id="#+id/linLoginText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="vertical" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/login_logo_white" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/newd_login_text_one"
android:textColor="#android:color/white"
android:textSize="24sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/newd_login_text_two"
android:textColor="#android:color/white"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linLoginFeature"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/btnLoginCreate"
android:layout_below="#+id/linLoginText"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp">
<ImageView android:id="#+id/imgLoginSecurity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#drawable/newd_security"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toRightOf="#+id/imgLoginSecurity"
android:layout_toEndOf="#+id/imgLoginSecurity"
android:layout_centerVertical="true"
android:text="#string/newd_login_security"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp">
<ImageView android:id="#+id/imgLoginAntivirus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#drawable/newd_antivirus"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toRightOf="#+id/imgLoginAntivirus"
android:layout_toEndOf="#+id/imgLoginAntivirus"
android:layout_centerVertical="true"
android:text="#string/newd_login_antivirus"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp">
<ImageView android:id="#+id/imgLoginTracker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#drawable/newd_phone_tracker"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toRightOf="#+id/imgLoginTracker"
android:layout_toEndOf="#+id/imgLoginTracker"
android:layout_centerVertical="true"
android:text="#string/newd_login_booster"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp">
<ImageView android:id="#+id/imgLoginBackup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#drawable/newd_backup"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toRightOf="#+id/imgLoginBackup"
android:layout_toEndOf="#+id/imgLoginBackup"
android:layout_centerVertical="true"
android:text="#string/newd_login_backup"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp">
<ImageView android:id="#+id/imgLoginPrivacy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#drawable/newd_privacy"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toRightOf="#+id/imgLoginPrivacy"
android:layout_toEndOf="#+id/imgLoginPrivacy"
android:layout_centerVertical="true"
android:text="#string/newd_login_privacy"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp">
<ImageView android:id="#+id/imgLoginBooster"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#drawable/newd_signal_booster"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toRightOf="#+id/imgLoginBooster"
android:layout_toEndOf="#+id/imgLoginBooster"
android:layout_centerVertical="true"
android:text="#string/newd_login_tracker"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RelativeLayout>
</LinearLayout>
<Button
android:id="#+id/btnLoginCreate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginRight="20dp"
android:layout_marginEnd="20dp"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:layout_alignParentBottom="true"
android:background="#drawable/newd_login_btn"
android:gravity="center"
android:text="#string/newd_login_btn_text"
android:textColor="#android:color/black" />
</RelativeLayout>
Use android:layout_weight
<?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"
android:background="#drawable/newd_login_overlay"
android:orientation="vertical" >
<LinearLayout android:id="#+id/linLoginText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="vertical" >
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/login_logo_white" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/newd_login_text_one"
android:textColor="#android:color/white"
android:textSize="24sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/newd_login_text_two"
android:textColor="#android:color/white"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linLoginFeature"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="6"
android:layout_above="#+id/btnLoginCreate"
android:layout_below="#+id/linLoginText"
android:layout_marginLeft="5dp"
android:layout_marginStart="5dp"
android:orientation="vertical" >
<RelativeLayout
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp">
<ImageView android:id="#+id/imgLoginSecurity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#drawable/newd_security"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toRightOf="#+id/imgLoginSecurity"
android:layout_toEndOf="#+id/imgLoginSecurity"
android:layout_centerVertical="true"
android:text="#string/newd_login_security"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RelativeLayout>
<RelativeLayout
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp">
<ImageView android:id="#+id/imgLoginAntivirus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#drawable/newd_antivirus"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toRightOf="#+id/imgLoginAntivirus"
android:layout_toEndOf="#+id/imgLoginAntivirus"
android:layout_centerVertical="true"
android:text="#string/newd_login_antivirus"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RelativeLayout>
<RelativeLayout
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp">
<ImageView android:id="#+id/imgLoginTracker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#drawable/newd_phone_tracker"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toRightOf="#+id/imgLoginTracker"
android:layout_toEndOf="#+id/imgLoginTracker"
android:layout_centerVertical="true"
android:text="#string/newd_login_booster"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RelativeLayout>
<RelativeLayout
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp">
<ImageView android:id="#+id/imgLoginBackup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#drawable/newd_backup"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toRightOf="#+id/imgLoginBackup"
android:layout_toEndOf="#+id/imgLoginBackup"
android:layout_centerVertical="true"
android:text="#string/newd_login_backup"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RelativeLayout>
<RelativeLayout
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp">
<ImageView android:id="#+id/imgLoginPrivacy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#drawable/newd_privacy"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toRightOf="#+id/imgLoginPrivacy"
android:layout_toEndOf="#+id/imgLoginPrivacy"
android:layout_centerVertical="true"
android:text="#string/newd_login_privacy"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RelativeLayout>
<RelativeLayout
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp">
<ImageView android:id="#+id/imgLoginBooster"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="#drawable/newd_signal_booster"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_toRightOf="#+id/imgLoginBooster"
android:layout_toEndOf="#+id/imgLoginBooster"
android:layout_centerVertical="true"
android:text="#string/newd_login_tracker"
android:textColor="#android:color/white"
android:textSize="18sp" />
</RelativeLayout>
</LinearLayout>
<Button
android:id="#+id/btnLoginCreate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_marginRight="20dp"
android:layout_marginEnd="20dp"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:layout_alignParentBottom="true"
android:background="#drawable/newd_login_btn"
android:gravity="center"
android:text="#string/newd_login_btn_text"
android:textColor="#android:color/black" />
</RelativeLayout>
I have a floating action button over a listview, but I can't click on the button when the list fills up so that the button and the list overlap. In that situation only the list item is clickable. How do I rectify this issue? Thanks in advance. My xml code is below.
<?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="wrap_content">
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
card_view:cardCornerRadius="1dp"
card_view:cardElevation="5dp">
<RelativeLayout
android:id="#+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/frameLayout"
android:layout_centerHorizontal="true"
android:layout_gravity="bottom"
android:background="#000000"
android:orientation="vertical"
android:padding="1.5dp"
android:weightSum="1">
<TextView
android:id="#+id/txtTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="#660033"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/primary_text_dark" />
<RelativeLayout
android:id="#+id/frameLayout"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="29dp"
android:background="#android:color/darker_gray"
android:padding="2dp">
<TextView
android:id="#+id/txtLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/dispLoc"
android:layout_gravity="left|top"
android:text="[Location]"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/txtDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/dispDesc"
android:layout_gravity="left|center_vertical"
android:layout_marginTop="1dp"
android:text="[Description]"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/dispLoc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text="#string/loc"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/dispDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/txtLocation"
android:layout_gravity="left|center_vertical"
android:layout_marginTop="17dp"
android:text="#string/desc"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/dispContact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/txtDesc"
android:layout_marginTop="25dp"
android:text="#string/contact"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/txtContact"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/dispContact"
android:layout_toEndOf="#+id/dispLoc"
android:autoLink="email"
android:text="[ContactInfo]"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/From"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/dispContact"
android:layout_marginTop="16dp"
android:text="#string/from"
android:textColor="#android:color/primary_text_light" />
<TextView
android:id="#+id/txtStartDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/From"
android:layout_marginLeft="10dp"
android:layout_toEndOf="#+id/From"
android:text="[Start Date]"
android:textColor="#android:color/secondary_text_light" />
<TextView
android:id="#+id/To"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="#+id/txtStartDate"
android:text="#string/to"
android:textColor="#android:color/primary_text_light" />
<TextView
android:id="#+id/txtEndDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/txtStartDate"
android:layout_alignTop="#+id/To"
android:text="[End Date]"
android:textColor="#android:color/secondary_text_light" />
<Button
android:id="#+id/attend_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:text="Attend" />
<Button
android:id="#+id/cancel_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignStart="#+id/txtContact"
android:text="Cancel" />
</RelativeLayout>
<TextView
android:id="#+id/txtType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/txtTitle"
android:layout_alignEnd="#+id/txtTitle"
android:text="Type"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/primary_text_dark" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<TextView
android:id="#+id/peopleAttending"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/card_view"
android:background="#660033"
android:text="#string/people_attending"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/primary_text_dark" />
<org.lucasr.twowayview.TwoWayView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/lvItems"
style="#style/TwoWayView"
android:layout_width="match_parent"
android:layout_height="37dp"
android:layout_below="#+id/peopleAttending"
android:drawSelectorOnTop="false"
tools:context=".DetailedEventActivity" />
<com.software.shell.fab.ActionButton xmlns:fab="http://schemas.android.com/apk/res-auto"
android:id="#+id/action_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="#dimen/fab_margin"
android:layout_marginEnd="#dimen/fab_margin"
fab:button_color="#color/fab_material_red_500"
fab:button_colorPressed="#color/fab_material_red_900"
fab:hide_animation="#anim/fab_roll_to_down"
fab:image="#drawable/fab_plus_icon"
fab:image_size="24dp"
fab:shadow_color="#757575"
fab:shadow_radius="1.0dp"
fab:shadow_xOffset="0.5dp"
fab:shadow_yOffset="1.0dp"
fab:show_animation="#anim/fab_roll_from_down"
fab:stroke_color="#color/fab_material_blue_grey_500"
fab:stroke_width="1.0dp"
fab:type="DEFAULT"
android:clickable="true"/>
<ListView
android:id="#+id/commentsList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/lvItems"
android:layout_marginTop="0dp"
/>
Move your FAB to the bottom of the XML (below the ListView).
I have a screen with relative layouts which contains images and text views.I am trying to add one text view but it is not showing up..I can't find out the reason.This is my whole xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#drawable/orangestrip"
android:gravity="left|center"
android:text="Choose your flag, Pay in your Home currency"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/textView1"
android:background="#drawable/orangestrip"
android:gravity="left|center"
android:text="اختيار العلم الخاص بك، ودفع بالعملة المحلية الخاصة بك"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#ffffff" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="#drawable/stripblue"
android:gravity="center"
android:text="Cancel"
android:textColor="#ffffff" />
<RelativeLayout
android:id="#+id/relativeLayout2"
android:layout_width="450dp"
android:layout_height="500dp"
android:layout_above="#+id/button1"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/textView4"
android:background="#drawable/imageborder" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="450dp"
android:layout_height="500dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#drawable/imageborder" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="400dp"
android:layout_height="320dp"
android:layout_above="#+id/textView2"
android:layout_centerHorizontal="true"
android:layout_marginBottom="17dp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/imageButton1"
android:layout_alignParentBottom="true"
android:layout_marginLeft="85dp"
android:text="curr"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="35sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView2"
android:layout_alignLeft="#+id/textView2"
android:gravity="center"
android:text="rate"
android:textColor="#android:color/black" />
</RelativeLayout>
<RelativeLayout
android:layout_width="450dp"
android:layout_height="500dp"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/relativeLayout1"
android:background="#drawable/imageborder" >
<ImageButton
android:id="#+id/imageButton2"
android:layout_width="400dp"
android:layout_height="320dp"
android:layout_above="#+id/textView3"
android:layout_centerHorizontal="true"
android:layout_marginBottom="16dp"
android:background="#drawable/uae" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/imageButton2"
android:layout_marginRight="123dp"
android:text="curr"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="35sp"
android:textStyle="bold" />
</RelativeLayout>
</RelativeLayout>
<ImageView
android:id="#+id/imageView1"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_above="#+id/relativeLayout2"
android:layout_alignParentRight="true"
android:background="#null"
android:src="#drawable/mashreqlogosmall" />
</RelativeLayout>
</LinearLayout>
This is the relative layout where I am trying to add the text view but its not showing up...textview with id textview5 is not showing up.
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="450dp"
android:layout_height="500dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#drawable/imageborder" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="400dp"
android:layout_height="320dp"
android:layout_above="#+id/textView2"
android:layout_centerHorizontal="true"
android:layout_marginBottom="17dp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/imageButton1"
android:layout_alignParentBottom="true"
android:layout_marginLeft="85dp"
android:text="curr"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="35sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView2"
android:layout_alignLeft="#+id/textView2"
android:gravity="center"
android:text="rate"
android:textColor="#android:color/black" />
</RelativeLayout>
please help..
try like this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relativeLayout1"
android:layout_width="450dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#drawable/ic_launcher" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="400dp"
android:layout_height="320dp"
android:layout_above="#+id/textView5"
android:layout_centerHorizontal="true"
android:layout_marginBottom="17dp" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/imageButton1"
android:layout_alignParentBottom="true"
android:layout_marginLeft="85dp"
android:text="curr"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="35sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/textView2"
android:layout_alignLeft="#+id/textView2"
android:gravity="center"
android:text="rate"
android:textColor="#android:color/black" />
</RelativeLayout>
I'm trying to use scrollview in an app, but it doesn't work, the scroll bar doesn't appear and the buttons overlap, I'm using RelativeLayout to do this, I tried by other ways, but it doesn't work too.
Does someone know what I have to do?
Here is the code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="81dp"
android:layout_height="61dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:text="#string/Texto14"
android:id="#+id/buttonHomePerfilV"
android:textColor="#ffffff"
android:background="#333399"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="291dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/buttonIDAmizadePerfilV"
android:layout_marginBottom="70dp"
android:text="#string/Texto15"
android:id="#+id/buttonIniciarConversaPerfilV"
android:textColor="#ffffff"
android:background="#333399"
android:layout_above="#+id/buttonIDAmizadePerfilV"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="291dp"
android:layout_height="wrap_content"
android:text="#string/Texto16"
android:id="#+id/buttonIDAmizadePerfilV"
android:layout_marginBottom="20dp"
android:textColor="#ffffff"
android:background="#333399"
android:layout_alignParentBottom="true"
android:layout_alignStart="#+id/buttonIniciarConversaPerfilV" />
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="#+id/imageViewPerfilV"
android:src="#drawable/ic_launcher"
android:layout_below="#+id/buttonHomePerfilV"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/Texto8"
android:id="#+id/textViewNomePerfilV"
android:layout_below="#+id/imageViewPerfilV"
android:layout_alignStart="#+id/buttonHomePerfilV" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/Texto9"
android:id="#+id/textViewCursoPerfilV"
android:layout_toEndOf="#+id/buttonHomePerfilV"
android:layout_centerVertical="true"
android:layout_alignStart="#+id/textViewNomePerfilV" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/Texto10"
android:id="#+id/textViewDataPerfilV"
android:layout_alignTop="#+id/textViewCursoPerfilV"
android:layout_marginTop="45dp"
android:layout_marginLeft="20dp"
android:layout_alignParentStart="true" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Try it. I just removed Parent Layout RelativeLayout:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="#+id/buttonHomePerfilV"
style="?android:attr/buttonStyleSmall"
android:layout_width="81dp"
android:layout_height="61dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:background="#333399"
android:text="#string/Texto14"
android:textColor="#ffffff" />
<Button
android:id="#+id/buttonIniciarConversaPerfilV"
android:layout_width="291dp"
android:layout_height="wrap_content"
android:layout_above="#+id/buttonIDAmizadePerfilV"
android:layout_alignBottom="#+id/buttonIDAmizadePerfilV"
android:layout_centerHorizontal="true"
android:layout_marginBottom="70dp"
android:background="#333399"
android:text="#string/Texto15"
android:textColor="#ffffff" />
<Button
android:id="#+id/buttonIDAmizadePerfilV"
android:layout_width="291dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignStart="#+id/buttonIniciarConversaPerfilV"
android:layout_marginBottom="20dp"
android:background="#333399"
android:text="#string/Texto16"
android:textColor="#ffffff" />
<ImageView
android:id="#+id/imageViewPerfilV"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_below="#+id/buttonHomePerfilV"
android:layout_centerHorizontal="true"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/textViewNomePerfilV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/buttonHomePerfilV"
android:layout_below="#+id/imageViewPerfilV"
android:layout_marginTop="20dp"
android:text="#string/Texto8"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textViewCursoPerfilV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/textViewNomePerfilV"
android:layout_centerVertical="true"
android:layout_toEndOf="#+id/buttonHomePerfilV"
android:text="#string/Texto9"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="#+id/textViewDataPerfilV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignTop="#+id/textViewCursoPerfilV"
android:layout_marginLeft="20dp"
android:layout_marginTop="45dp"
android:text="#string/Texto10"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
</ScrollView>
You cannot use a RelativeLayout inside a ScrollView put the RelativeLayout inside a LinearLayout
Try this
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Linearlayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="81dp"
android:layout_height="61dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:text="#string/Texto14"
android:id="#+id/buttonHomePerfilV"
android:textColor="#ffffff"
android:background="#333399"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="291dp"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/buttonIDAmizadePerfilV"
android:layout_marginBottom="70dp"
android:text="#string/Texto15"
android:id="#+id/buttonIniciarConversaPerfilV"
android:textColor="#ffffff"
android:background="#333399"
android:layout_above="#+id/buttonIDAmizadePerfilV"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="291dp"
android:layout_height="wrap_content"
android:text="#string/Texto16"
android:id="#+id/buttonIDAmizadePerfilV"
android:layout_marginBottom="20dp"
android:textColor="#ffffff"
android:background="#333399"
android:layout_alignParentBottom="true"
android:layout_alignStart="#+id/buttonIniciarConversaPerfilV" />
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="#+id/imageViewPerfilV"
android:src="#drawable/ic_launcher"
android:layout_below="#+id/buttonHomePerfilV"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/Texto8"
android:id="#+id/textViewNomePerfilV"
android:layout_below="#+id/imageViewPerfilV"
android:layout_alignStart="#+id/buttonHomePerfilV" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/Texto9"
android:id="#+id/textViewCursoPerfilV"
android:layout_toEndOf="#+id/buttonHomePerfilV"
android:layout_centerVertical="true"
android:layout_alignStart="#+id/textViewNomePerfilV" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="#string/Texto10"
android:id="#+id/textViewDataPerfilV"
android:layout_alignTop="#+id/textViewCursoPerfilV"
android:layout_marginTop="45dp"
android:layout_marginLeft="20dp"
android:layout_alignParentStart="true" />
</RelativeLayout>
</linearlayout>
</scrollview>