user3326228
user3326228

Reputation: 51

Placing android button in a particular place

I want to place the Android button1 in a Specific place in Android screen, but depends on the TextView1 size it showing in different places.

How i can place the android button in a particular place

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".InfoActivity" >
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:orientation="vertical" 
        android:background="@drawable/backquiz">
        <TextView
            android:id="@+id/textView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/question1"
            android:text="Large Text"
            android:textAppearance="?android:attr/textAppearanceLarge" />
            <Button
                android:id="@+id/button1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge" 
                android:background="@drawable/next"/>

    </LinearLayout>
</RelativeLayout>

I need the Next button to be present in Bottom.

Here is the image

Upvotes: 1

Views: 89

Answers (3)

Pragnesh Ghoda  シ
Pragnesh Ghoda シ

Reputation: 8337

Try Below code to solve your problem

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
            <TextView
                android:id="@+id/textView1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:text="Large Text"
                android:textAppearance="?android:attr/textAppearanceLarge" />

                <Button
                    android:id="@+id/button1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true" //set this propery to align your button in bottom
                    android:layout_centerHorizontal="true"  //set this propery to align your button in center
                    android:background="@drawable/next"
                    />

    </RelativeLayout>

Upvotes: 2

learner
learner

Reputation: 3110

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".InfoActivity" >
        <TextView
            android:id="@+id/textView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/question1"
            android:text="Large Text"
            android:textAppearance="?android:attr/textAppearanceLarge" />
            <Button
                android:id="@+id/button1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge" 
                android:background="@drawable/next"
                android:layout_below="@+id/textView1"/>

</RelativeLayout>

Upvotes: 1

PareekSandeep
PareekSandeep

Reputation: 430

Use relative layout for button. here is the link.

Upvotes: 2

Related Questions