Hi All,
I am looking to create a custom button. The button needs to contain a title and separate subtitle text (pulled from separate SQL fields) as well as an icon (blue) and image (pink), again separate db fields - see image below. This component needs to be easily reusable and the text colour needs to be able to change based on its highlight/pressed state (this bit im ok with).
I was hoping to do this all in XML then just programmatically update the text and image source once the query had returned. I had tried expanding on the button component in XML by nesting an <ImageView/> and <TextView/> inside but it seems that <Button> is not a container and cannot be used in such a way.
I am now creating a RelativeLayout that contains a Button, 2xTextView's and ImageViews etc...
testbutton.xml
How do i go about referencing this layout object in another XML?
I know what i have written below is not right but im after something like it...
activity_main.xml
Again, not looking to be given the answer (unless such components have already been created!) but would like a nudge in the right direction.
Thanks in advance
I am looking to create a custom button. The button needs to contain a title and separate subtitle text (pulled from separate SQL fields) as well as an icon (blue) and image (pink), again separate db fields - see image below. This component needs to be easily reusable and the text colour needs to be able to change based on its highlight/pressed state (this bit im ok with).
I was hoping to do this all in XML then just programmatically update the text and image source once the query had returned. I had tried expanding on the button component in XML by nesting an <ImageView/> and <TextView/> inside but it seems that <Button> is not a container and cannot be used in such a way.
I am now creating a RelativeLayout that contains a Button, 2xTextView's and ImageViews etc...
testbutton.xml
Code:
<?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="vertical" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center" >
<Button
android:id="@+id/btnTest"
... />
<ImageView
android:id="@+id/imgIcon"
.../>
<ImageView
android:id="@+id/imgMain"
.../>
<TextView
android:id="@+id/txtTitle"
... />
<TextView
android:id="@+id/txtSubTitle"
... />
</FrameLayout>
</LinearLayout>
How do i go about referencing this layout object in another XML?
I know what i have written below is not right but im after something like it...
activity_main.xml
Code:
...
<testbutton
Again, not looking to be given the answer (unless such components have already been created!) but would like a nudge in the right direction.
Thanks in advance