Reputation: 133
This is a Very simple layout I hope to achieve on. However, I tried many ways to make my customView appear at the side of the Buttons - LinearLayout. But I failed. Any help would be greatly appreciated!
Thank you!
This is where I declare my CustomView at MainActivity.
public class Drawing extends Activity {
mContent = (LinearLayout) findViewById(R.id.labelCreator);
mSignature = new Resize(this, null);
mContent.addView(mSignature);
...........
My XML Layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
android:id="@+id/Drawing"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:visibility="visible" >
<LinearLayout
android:id="@+id/interface2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:layout_marginTop="0dp"
android:background="#8b5a2b"
android:orientation="horizontal" >
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TableRow
android:id="@+id/tableRow9"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/btnPhoto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/camera2"
android:text="Camera"
android:textColor="#ffffff"
android:textSize="25sp"
android:typeface="serif" />
<Button
android:id="@+id/btnImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/image"
android:text="Image"
android:textColor="#ffffff"
android:textSize="25sp"
android:typeface="serif" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/btnText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/text"
android:text="Text"
android:textColor="#ffffff"
android:textSize="25sp"
android:typeface="serif" />
<EditText
android:id="@+id/editText1"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:ems="10"
android:freezesText="false"
android:hint="text"
android:maxLength="10"
android:maxLines="1"
android:textAlignment="center"
android:textColor="#e6e6fa"
android:textSize="25sp"
android:typeface="serif"
android:visibility="visible" />
</TableRow>
<TableRow
android:id="@+id/tableRow3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Spinner
android:id="@+id/color_spinner"
android:layout_width="135dp"
android:layout_height="wrap_content"
android:textAlignment="center" />
<Spinner
android:id="@+id/fonts_spinner"
android:layout_width="132dp"
android:layout_height="wrap_content"
android:textAlignment="center"
app:context=".LabelCreator" />
</TableRow>
<TableRow
android:id="@+id/tableRow4"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="@+id/btnSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/save3"
android:text="Save"
android:textColor="#ffffff"
android:textSize="25sp"
android:typeface="serif" />
<Button
android:id="@+id/btnClear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableTop="@drawable/clear"
android:text="Clear"
android:textColor="#ffffff"
android:textSize="25sp"
android:typeface="serif" />
</TableRow>
</TableLayout>
</TableRow>
<Button
android:id="@+id/btnClose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="@drawable/close"
android:shadowColor="#00000000"
android:text="Close"
android:textColor="#ffffff"
android:textSize="25sp"
android:typeface="serif" />
<Button
android:id="@+id/btnAbout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="About"
android:textColor="#ffffff"
android:textSize="25sp"
android:typeface="serif" />
</TableLayout>
</LinearLayout>
<TextView
android:id="@+id/textView1"
android:layout_width="250dp"
android:layout_height="85dp"
android:maxLines="1"
android:singleLine="true"
android:text="TextView"
android:textSize="20sp"
android:visibility="invisible" />
</LinearLayout>
Upvotes: 1
Views: 337
Reputation: 10959
This is just a structure to follow
<?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="horizontal"
android:weightSum="10" >
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="3"
android:orientation="vertical" >
<Button
android:id="@+id/btnSave"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawableTop="@drawable/save3"
android:text="Save"
android:textColor="#ffffff"
android:textSize="25sp"
android:typeface="serif" />
<Button
android:id="@+id/btnClear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawableTop="@drawable/clear"
android:text="Clear"
android:textColor="#ffffff"
android:textSize="25sp"
android:typeface="serif" />
<Spinner
android:id="@+id/color_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAlignment="center" />
<Spinner
android:id="@+id/fonts_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
app:context=".LabelCreator" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="7" >
// your custom view(Drawing area) will be here.
</LinearLayout>
</LinearLayout>
Here the parent layout has android:orientation="horizontal"
so all its child layout will display in column-wise.
If you want row-wise display make android:orientation="vertical"
. Here I use vertical for the parent layout that have <Button>
and <Spinner>
controls.
you will make changes in it as per your need.
Hope this will help.
Upvotes: 1