5

我创建了轮播设计应用程序,它运行良好。我希望在屏幕中央显示一个默认徽标。所以我尝试了很多方法,请帮助我。

这是我的屏幕截图: 在此处输入图像描述

我希望在轮播设计的中心显示一个徽标。

这是我的xml源代码:

>

<LinearLayout
    android:layout_weight="0.5"
    android:padding="5dip"
    android:gravity="top"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    >
        <com.globems.controls.Carousel
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/carousel"  
            pj:UseReflection="true"
            pj:Items="@array/entries"
            pj:Names="@array/names" 
            pj:SelectedItem="0"
            android:animationDuration="200"
        />    
         <ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_launcher" />

</LinearLayout>     

在这段代码中,我使用 imageview 来显示徽标,但它不起作用。

更新的xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:pj="http://schemas.android.com/apk/res/com.globems.main"
    xmlns:bm="com.carousel.main"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background ="@drawable/blue3"

    >

    <RelativeLayout
        android:layout_weight="0.5"
        android:padding="5dip"
        android:gravity="top"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        >
            <com.globems.controls.Carousel
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:id="@+id/carousel"  
                pj:UseReflection="true"
                pj:Items="@array/entries"
                pj:Names="@array/names" 
                pj:SelectedItem="0"
                android:animationDuration="200"
            />    
        <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher"
        android:centerinHorizontal="true"
        />

    </RelativeLayout>       
</RelativeLayout>
4

1 回答 1

7

最好在 imageView 中使用RelativeLayout和添加android:centerinParent="true"...

更新 ::

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:pj="http://schemas.android.com/apk/res/com.globems.main"
    xmlns:bm="com.carousel.main"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/blue3" >

    <com.globems.controls.Carousel
        android:id="@+id/carousel"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        pj:Items="@array/entries"
        pj:Names="@array/names"
        pj:SelectedItem="0"
        pj:UseReflection="true"
        android:animationDuration="200" />

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

</RelativeLayout>
于 2012-05-12T12:32:45.120 回答