Add Textview Next To Buttons?
I have a layout with 4 buttons in the center. I simply want to add a textview next to the four buttons (WITHOUT MOVING THE FOUR BUTTONS FROM THE CENTER), like illustrated here (Tex
Solution 1:
Put the textView in one Linearlayout and the four buttons in another LinearLayout and then trying Horizontal weights to align then in a single line might work out.
Code could be as follows
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns: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"android:paddingBottom="@dimen/activity_vertical_margin"android:paddingLeft="@dimen/activity_horizontal_margin"android:paddingRight="@dimen/activity_horizontal_margin"android:paddingTop="@dimen/activity_vertical_margin"tools:context="com.example.ruchir.circleswithmap.MainActivity"android:id="@+id/layout"android:gravity="center"android:background="#010101"android:weightSum="100"><LinearLayoutandroid:id="@+id/text_container"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_above="@+id/relativeLayout"android:layout_centerHorizontal="true"android:layout_marginBottom="10dp"android:layout_weight = "50"
><TextViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:text="20:00"android:textAppearance="?android:attr/textAppearanceLarge"android:textSize="50sp"android:textColor="#fbfafa"android:id="@+id/timetext" /></LinearLayout><RelativeLayoutandroid:id="@+id/relativeLayout"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerInParent="true"android:layout_weight="50"><ImageButtonandroid:layout_width="150dp"android:layout_height="150dp"android:id="@+id/Blue"android:layout_alignParentTop="true"android:layout_alignParentLeft="true"android:layout_alignParentStart="true"
/><ImageButtonandroid:layout_width="150dp"android:layout_height="150dp"android:id="@+id/Green"android:layout_below="@+id/Blue"android:layout_alignLeft="@+id/Blue"android:layout_alignStart="@+id/Blue"
/><ImageButtonandroid:layout_width="150dp"android:layout_height="150dp"android:id="@+id/Red"android:layout_alignTop="@+id/Blue"android:layout_toRightOf="@+id/Blue"android:layout_toEndOf="@+id/Blue"
/><ImageButtonandroid:layout_width="150dp"android:layout_height="150dp"android:id="@+id/Purple"android:layout_alignBottom="@+id/Green"android:layout_alignLeft="@+id/Red"android:layout_alignStart="@+id/Red"
/></RelativeLayout></LinearLayout>
Post a Comment for "Add Textview Next To Buttons?"