如何将带有两个 TextView 的圆形图像靠近透明图像下方?我用 TextView 创建了透明图像,但我不知道如何用两个 TextView (即日期和日期)放置圆形图像。 如何达到预期的产出?
预期输出是:
这是我的代码。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#AAA" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/overlay_margin"
android:background="#FFF" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/salogo" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#7000"
android:orientation="vertical"
android:paddingBottom="15dp"
android:paddingTop="15dp" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Marathon for organ donation"
android:textColor="#CCC"
android:textSize="12sp"/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</ScrollView>
但我得到的输出是:
最佳答案
在drawable文件夹中创建circular_bg.xml
并写..
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<gradient
android:endColor="#3399FF"
android:startColor="#3399FF" />
<padding
android:bottom="1.5dp"
android:left="1.5dp"
android:right="1.5dp"
android:top="1.5dp" />
</shape>
现在在你的 xml 中
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="2dp" >
<TextView
android:id="@+id/text"
android:layout_width="40dp"
android:layout_height="40dp"
android:text="31 sun"
android:layout_centerInParent="true"
android:background="@drawable/circular_bg"
android:gravity="center"
android:textColor="#ffffff"
android:textStyle="bold" />
</RelativeLayout>
它会解决你的问题。
关于android - 如何将带有图像的圆形 TextView 放置在透明图像android附近?`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27775543/