Android 堆叠 View

标签 android

图中显示了我想要的 View 。

example

最佳答案

为此你可以采取 FrameLayout .

例如 - 1:

 <FrameLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android">
    <ImageView 
        android:src="@drawable/icon"
        android:scaleType="fitCenter"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"/>
    <TextView
        android:text="Learn-Android.com"
        android:textSize="24sp"
        android:textColor="#000000"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:gravity="center"/>
</FrameLayout>

更新:

例如 - 2:精湛的示例和技巧,可在此处找到:http://www.curious-creature.org/2009/03/01/android-layout-tricks-3-optimize-part-1/

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 

        android:scaleType="center"
        android:src="@drawable/golden_gate" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="20dip"
        android:layout_gravity="center_horizontal|bottom"

        android:padding="12dip"

        android:background="#AA000000"
        android:textColor="#ffffffff"

        android:text="Golden Gate" />

</FrameLayout>

关于Android 堆叠 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7544034/

相关文章:

java - Android服务和asynctask通信

android - 如何在 MPAndroidChart 中隐藏图例和轴?

带有单选按钮的Android双向数据绑定(bind)

c# - 使用2个单独的按钮Unity播放和停止音频

java - 在 Android 上针对多种屏幕分辨率时使用的最佳做法

android - 为什么我的 BroadcastReceiver 收不到来自其他应用程序的广播?

android - 引用错误 : Can't find variable __fbBatchedBridge

android - 当 primaryDark 为白色时更改状态栏文本颜色

Android手机号码验证流程

java - 当 : some keyboard keys are pressed and when user clicks on something else in the activity 时强制 EditText 失去焦点