Hello Guys!!
If you are facing issue to place image and text at center of any button then please refer my blog -
<?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="wrap_content"
android:orientation="vertical">
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow
android:layout_width="0dp"
android:layout_height="match_parent"
android:weightSum="4">
<RelativeLayout
android:id="@+id/layout_Views"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="@color/blue">
<TextView
android:id="@+id/txt_viewCount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:padding="9dp"
android:text="214 Views"
android:textColor="#fff" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/layout_Votes"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="@color/red">
<TextView
android:id="@+id/txt_Votes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:padding="9dp"
android:text="214 Views"
android:textColor="#fff" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/layout_share"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="@color/green">
<ImageView
android:id="@+id/img_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/ic_share" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/layout_bookmark"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="@color/yellow">
<ImageView
android:id="@+id/img_boomark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/ic_bookmark" />
</RelativeLayout>
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
Output is -
If you are facing issue to place image and text at center of any button then please refer my blog -
<?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="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TableLayoutandroid:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow
android:layout_width="0dp"
android:layout_height="match_parent"
android:weightSum="4">
<RelativeLayout
android:id="@+id/layout_Views"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="@color/blue">
<TextView
android:id="@+id/txt_viewCount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:padding="9dp"
android:text="214 Views"
android:textColor="#fff" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/layout_Votes"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="@color/red">
<TextView
android:id="@+id/txt_Votes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
android:padding="9dp"
android:text="214 Views"
android:textColor="#fff" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/layout_share"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="@color/green">
<ImageView
android:id="@+id/img_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/ic_share" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/layout_bookmark"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_margin="2dp"
android:layout_weight="1"
android:background="@color/yellow">
<ImageView
android:id="@+id/img_boomark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/ic_bookmark" />
</RelativeLayout>
</TableRow>
</TableLayout>
</LinearLayout>
</LinearLayout>
Output is -
No comments:
Post a Comment