如何创建stampcard类型布局?

时间:2013-08-15 15:13:14

标签: android xml layout relativelayout

我试图在我的应用程序上创建一个印章卡系统,但是当它到来铺设邮票时(它们将被隐藏起来,直到请求并且应该以3个2xrows的间隔均匀分布),

我不能让视图坐得正确,我希望邮票在图像视图上均匀显示但它不会发生,我试图让我的线性布局将两行拉伸到相对视图(谁是尺寸是由印章卡ImageView设置的,所以我可以使用它们的重量均匀地将它们分开,但是它不会拉伸它会总是包装内容,任何帮助都会被欣赏。

布局xml:

<?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" >

<RelativeLayout
    android:id="@+id/main_fragment_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

<TextView
    android:id="@+id/home_page_title"
    android:layout_width="match_parent"
    android:layout_height="64dp"
    android:background="@drawable/bottom_bar"
    android:gravity="center_horizontal|fill_vertical"
    android:text="@string/home_fragment_title"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="#FFFFFF"
    android:textStyle="bold" />

<RelativeLayout
    android:id="@+id/stamp_card_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/home_page_title"
    android:gravity="center" >

    <ImageView
        android:id="@+id/the_stamp_card"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:src="@drawable/stamp_card" />

    <LinearLayout
        android:id="@id/row_holder"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1" >

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/stamp" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1" >

            <ImageView
                android:id="@+id/imageView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/stamp" />

        </LinearLayout>

    </LinearLayout>

</RelativeLayout>

<Button
    android:id="@+id/scanBtn"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/stamp_card_layout"
    android:background="@drawable/brown_btn"
    android:text="Scan?"
    android:textColor="#FFFFFF"
    android:textSize="23sp"
    android:textStyle="bold"
    android:typeface="normal" />

</RelativeLayout>

结果:

Result of the layout

我不知道该怎么办,因为他们必须在图像上并保持相对于标记卡,这是我知道如何使用相对布局的唯一方法,它是为api 8设计的,所以它必须是简单:/

先谢谢!

1 个答案:

答案 0 :(得分:0)

我遇到的解决方案是只有多张Stampcard图像,每张图片的图章比最后一张还多一张,并循环使用。