utdev utdev - 14 days ago 7
Android Question

Android layout button next to 3 textviews

I currently have a layout which holds 3 textviews.

My question is how to create a button next to those textviews.

Currently my code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/activity_horizontal_margin">

<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="2dip"
android:paddingTop="6dip"
android:textColor="@color/colorPrimaryDark"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="2dip"
android:textColor="@color/colorAccent" />
<TextView
android:id="@+id/release_at"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#5d5d5d"
android:textStyle="bold" />

</LinearLayout>


This creates me 3 Textviews, my idea is to put a button right to the textviews, but I do not know how to do that properly.

Answer

Like this:

<LinearLayout
    heigth=match_parent
    width=match_parent
    orientation=horizontal
    <LinearLayout
        heigth=match_parent
        width=0dp
        layout_weigth=1
        orientation=vertical
        //Your textviews
    </LinearLayout>
    <LinearLayout
        heigth=match_parent
        width=0dp
        layout_weigth=1
        orientation=vertical
        gravity="center"
        //Your button
    </LinearLayout>
</LinearLayout>
Comments