Reputation: 927
I made the following xml document as a custom designed button:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/CBN_LinearLayout"
style="@android:style/Widget.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:fadingEdge="horizontal" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="4dp"
android:layout_marginTop="1dp"
android:contentDescription="@string/redcirclenotify"
android:src="@drawable/rednotify"
android:visibility="visible" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/CBV_texview1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:gravity="right"
android:text="@string/checkorder" />
<TextView
android:id="@+id/CBV_textview2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="left"
android:text="@string/zero"
android:visibility="visible" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/CBV_textview3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fadingEdge="horizontal"
android:gravity="center_horizontal"
android:text="@string/blankstring" />
<TextView
android:id="@+id/CBV_textview4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="@string/blankstring" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
</LinearLayout>
I would like to know if I can make this an accessible view in the custom section in the ADK without having to create a custom class. If I must create a custom class extending view is there a way to reference this layout for the specifics as I would rather not program it in the class.
Thanks for any insight!
Upvotes: 0
Views: 178
Reputation: 28823
You can use inflation for it in java file.
final LayoutInflater lyInflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout lLayout = (LinearLayout) lyInflater.inflate(
R.layout.my_xml, null);
Or you can include it in xml file.
Upvotes: 1
Reputation: 1760
You can always refernce this layout whereevr required .just include this layout in ur other layout xml whereevr required like this:
<include
android:layout_width="fill_parent"
android:layout_x="0px"
android:layout_y="0px"
layout="@layout/ur custom layout" />
Can refer this
Upvotes: 3