Reputation:
I have a LinearLayout and i just want to put a text at the middle of my imageview which is a shape.
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<TextView
android:id="@+id/state_area"
android:layout_width="wrap_content"
android:textColor="#F000"
android:layout_height="90dp"
android:textSize="40sp"
android:layout_marginBottom="24dp"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/shape"
android:layout_gravity="center" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:src="@drawable/shape"
android:layout_gravity="center" />
</LinearLayout>
The result so far :
Upvotes: 0
Views: 135
Reputation: 73
Wrap your image and textview in framelayout
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<FrameLayout android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:src="@drawable/shape"
android:layout_gravity="center" />
<TextView
android:id="@+id/state_area"
android:layout_width="wrap_content"
android:textColor="#F000"
android:layout_height="90dp"
android:textSize="40sp"
android:gravity:"center"
android:layout_marginBottom="24dp"
android:layout_gravity="center" />
</FrameLayout>
<FrameLayout android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:src="@drawable/shape"
android:layout_gravity="center" />
<TextView
android:id="@+id/state_area2"
android:layout_width="wrap_content"
android:textColor="#F000"
android:layout_height="90dp"
android:textSize="40sp"
android:gravity:"center"
android:layout_marginBottom="24dp"
android:layout_gravity="center" />
</FrameLayout>
</LinearLayout>
Upvotes: 0
Reputation: 2795
you could just use a textview and set the shape as the background.
<TextView
android:id="@+id/state_area"
android:layout_width="wrap_content"
android:textColor="#F000"
android:layout_height="90dp"
android:background="@drawable/shape"
android:textSize="40sp"
android:layout_marginBottom="24dp"
android:layout_gravity="center_horizontal" />
Upvotes: 0
Reputation: 123
You can use Relative layout to arrange the layout on top of another. Or your can use a custom circle drawable as the background to the textview
Upvotes: 1