I’d like to right align this gridview so that it’s flush against the right side of the screen, but it seems to always immediately follow whichever textview I set it to the right of. Not only that, but all of the textviews are displayed on top of each other.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/time_left"
android:textSize="30sp"
android:layout_alignParentLeft="true"
android:id="@+id/time_left_label"/>
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/time_left"
android:layout_alignParentLeft="true"
android:layout_below="@id/time_left_label"/>
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/progress"
android:textSize="30sp"
android:layout_alignParentLeft="true"
android:layout_below="@id/time_left"
android:id="@+id/progress_label" />
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/progress"
android:layout_alignParentLeft="true"
android:layout_below="@id/progress_label"/>
<GridView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/main_grid"
android:numColumns="2"
android:layout_alignParentRight="true"
android:layout_toRightOf="@id/time_left_label"
android:stretchMode="none" />
</RelativeLayout>
Here’s a picture of what I want drawn quickly in paint!
https://i.stack.imgur.com/cXX5M.jpg
How exactly do you want it aligned? You mention what it does, but not what you want.
Welll, you’re using
layout_alignParentRightandlayout_toRightOf.Placing your
TextViewsunderneath each other won’t stack them. You can use aLinearLayoutwith itsorientationset toverticalor you could uselayout_belowto place them under each other.