需要帮助设计Android UI

时间:2012-06-20 00:41:38

标签: android user-interface

我正在设计一个像Android这样的屏幕:

sample image

我将所有按钮,背景和图像都放在单独的PNG文件中,但我无法完成! 我不知道如何将两个按钮放在背景中,我也遇到了与边界距离的麻烦。 以下是我到目前为止的情况:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" 
    android:background="@drawable/fundo_tela">
    <ImageView
    android:id="@+id/imgtopo"
    android:src="@drawable/topo"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    />
  <TextView  
        android:layout_width="fill_parent"  
        android:layout_height="wrap_content"  
        android:text="@string/telaInicio"  
        android:layout_gravity="center"  
        android:gravity="center"  
        android:textColor="#fff"  
        android:textSize="20dp" /> 


    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
                android:layout_marginTop="5dp"
                        android:layout_marginBottom="5dp"
        android:background="@drawable/fundoBotoes" >

<Button  android:id="@+id/Camera" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@color/cameraBselector">
</Button>
<Button 
    android:id="@+id/Galeria" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:background="@color/galleryBselector">
</Button>
</LinearLayout>
<Button 
    android:id="@+id/Pedidos" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:background="@color/pedidosBselector"
    android:layout_marginTop="15dp"
    android:layout_marginBottom="15dp"
    >
</Button>
</LinearLayout>

3 个答案:

答案 0 :(得分:0)

当你说“两个按钮”时,我认为你正在谈论的是画廊和相机按钮。

如果我理解正确你可以做这样的事情(我没有正确测试,所以你可能想做一些额外的改动)

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    android:orientation="vertical"
    android:background="#000000"
    android:gravity="center"
>
    <Button  
        android:id="@+id/Camera" 
        android:layout_width="wrap_content"  
        android:layout_height="wrap_content" 
        android:layout_margin="5sp"
        android:background="@color/cameraBselector"
    >
    </Button>
    <View
        android:layout_width="fill_parent"
        android:layout_height="1dip"
        android:layout_margin="3sp"
        android:background="#41383C"
    />
    <Button 
        android:id="@+id/Galeria" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_margin="3sp"
        android:background="@color/galleryBselector"
    />

</LinearLayout>

如果我误解了某些内容,请告诉我。

答案 1 :(得分:0)

试试这个

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/fundo_tela"
    android:layout_weight="100"

    android:orientation="vertical" >

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="0px"
        android:layout_weight="20"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_marginTop="5dp"

        android:orientation="vertical" >

        <ImageView
            android:id="@+id/imgtopo"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/topo" />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center"
            android:text="@string/telaInicio"
            android:textColor="#fff"
            android:textSize="20dp" />
    </LinearLayout>

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="0px"
        android:layout_weight="60"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_marginTop="5dp"
        android:background="@drawable/fundoBotoes"
        android:orientation="vertical" >

        <Button
            android:id="@+id/Camera"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@color/cameraBselector" >
        </Button>

        <Button
            android:id="@+id/Galeria"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@color/galleryBselector" >
        </Button>
    </LinearLayout>

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
                android:layout_height="0px"
        android:layout_weight="20"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:layout_marginTop="5dp"

        android:orientation="vertical" >

        <Button
            android:id="@+id/Pedidos"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="15dp"
            android:layout_marginTop="15dp"
            android:background="@color/pedidosBselector" >
        </Button>
    </LinearLayout>

</LinearLayout>

仅对Linearlayout中的第一个imageview和文本以及其他LinearLayout中的最后一个按钮进行分组。权重属性的工作方式类似于百分比,此示例为20%top,60%body和20%footer。

答案 2 :(得分:0)

确切地看你想要的是什么。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<ImageView
    android:id="@+id/imgtopo"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_launcher" />


<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/darker_gray"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center"
        android:paddingTop="10dp"
        android:text="Selecione a opção desejada:"
        android:textColor="#fff"
        android:textSize="18dp"
        android:textStyle="bold" />

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:layout_weight="0.90"
        android:background="@android:color/black"
        android:gravity="center"
        android:orientation="vertical" >

        <Button
            android:id="@+id/ButtonCamera"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.50"
            android:layout_margin="10dp"
            android:drawablePadding="-5sp"
            android:drawableTop="@android:drawable/ic_menu_camera"
            android:text="Tirar Foto"
            android:textColor="#FFFFFF" />

        <Button
            android:id="@+id/ButtonSlideShow"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0.50"
            android:layout_margin="10dp"
            android:drawablePadding="-5sp"
            android:drawableTop="@android:drawable/ic_menu_slideshow"
            android:text="Galeria de Foto"
            android:textColor="#FFFFFF" />
    </LinearLayout>

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Meus Pedidos" />
</LinearLayout>