Ich möchte etwas Text über das Bild setzen. Kann mir bitte jemand dabei helfen?Wie setze ich Text über mehrere Bilder in einem LinearLayout?
Ich habe sechs rechteckige Box und ich möchte etwas Text auf jeder Box setzen. Ich habe ImageView
verwendet, um die Rechtecke zu machen.
finden Sie die unten mainactivity.xml Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.example.vimal.edkul.StudentProfile">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/layout1">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/title">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:src="@drawable/pic13" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="User Profile"
android:textSize="20sp"
android:textColor="@android:color/white" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:src="@drawable/ic_action_overflow" />
</android.support.v7.widget.Toolbar>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/layout2"
android:layout_gravity="center"
android:layout_below="@+id/layout1"
android:padding="30dp">
<FrameLayout
android:layout_height="100dp"
android:layout_width="130dp">
<View
android:background="@drawable/rectangle"
android:clickable="false"
android:id="@+id/view1"
android:layout_height="match_parent"
android:layout_width="match_parent" />
<TextView
android:gravity="center"
android:id="@+id/text1"
android:textColor="#000"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:text="Some text" />
</FrameLayout>
<FrameLayout
android:layout_height="100dp"
android:layout_width="130dp">
<View
android:background="@drawable/rectangle"
android:clickable="false"
android:id="@+id/view2"
android:layout_height="match_parent"
android:layout_width="match_parent" />
<TextView
android:gravity="center"
android:id="@+id/text2"
android:textColor="#000"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:text="Some text" />
</FrameLayout>
</LinearLayout>
</RelativeLayout>
rectangle.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="@android:color/transparent"/>
<corners android:radius="12px"/>
<stroke android:width="2dip" android:color="#000000"/>
</shape>
Verwenden framelayout anstelle von linearlayout –
@ payaltuteja danke für die antwort. Ich bin neu bei android wenn ich framelayout so wie kann ich text über ein bild kann mir ein beispiel geben bitte das wird mir helfen, besser zu verstehen. –
Möchten Sie Text in Bitmaps von Bildern einfügen? Oder Platzieren von Text in Standard-TextViews und das Platzieren dieser TextViews vor ImageViews reicht aus? –