1
是否可以将另一个布局设置为视图的背景?Android:将布局设置为视图的背景
我正在做的是有一个文本视图,在我的网格视图后执行倒计时。
我已经尝试将我的布局设置为我的网格视图的背景资源,但它似乎只希望绘制一个drawable。
什么是最好的解决方法?我会如何将这种布局叠加在网格视图后面,并可能使用透明背景?
是否可以将另一个布局设置为视图的背景?Android:将布局设置为视图的背景
我正在做的是有一个文本视图,在我的网格视图后执行倒计时。
我已经尝试将我的布局设置为我的网格视图的背景资源,但它似乎只希望绘制一个drawable。
什么是最好的解决方法?我会如何将这种布局叠加在网格视图后面,并可能使用透明背景?
FrameLayout可以用来在其他东西上堆叠东西。
下面是一个示例,我将HelloGridView代码和我自己的文本视图布局(试图模拟您的计数器)相结合。结果是GridView显示狗图片,并且计数器TextViews在上面浮动。
希望这可以帮助你。
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/frameLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<GridView
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:columnWidth="90dp"
android:gravity="center"
android:horizontalSpacing="10dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp" />
<LinearLayout
android:id="@+id/counterLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/counterLabel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:gravity="center"
android:text="Counter" />
<TextView
android:id="@+id/counterValue"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:gravity="center"
android:text="128"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</FrameLayout>
完美的作品,谢谢 – DJ180 2012-02-11 18:23:11