正确制作布局的建议

时间:2017-03-22 09:39:35

标签: android layout

我想为客户制作一个特定的布局,但它不能与我合作(忽略语言差异)看看设计的背景是如何具有alpha而在我的布局中却没有。 这是我的xml代码:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:background="@drawable/bg"
android:fitsSystemWindows="true">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg"
    android:orientation="vertical"
    android:id="@+id/rootLayout"
    android:visibility="visible"
    android:gravity="center" >

    <include
        android:id="@+id/top"
        layout="@layout/top_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_gravity="center_vertical|center_horizontal"
        android:gravity="center"
        android:id="@+id/ivTeam"
        android:clickable="false"
        android:layout_centerInParent="true"
        android:focusable="false"
        android:alpha="0.5"
        android:focusableInTouchMode="false"
        android:layout_height="wrap_content" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_below="@+id/top"
        android:weightSum="8"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_marginTop="32dp"
            android:weightSum="2"
            android:layout_weight="2">


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:id="@+id/firstRow"
                android:layout_marginStart="32dp"
                android:layout_weight="1"
                android:layout_marginEnd="32dp"
                android:layout_marginBottom="4dp"
                android:orientation="horizontal">

                <RelativeLayout
                    android:id="@+id/rlDraws"
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:background="@color/top_blue"
                    android:layout_marginTop="8dp"
                    android:layout_marginBottom="8dp"
                    android:layout_marginStart="4dp"
                    android:layout_marginEnd="4dp"
                    android:layout_height="wrap_content">



                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_above="@+id/tvDraw"
                        android:gravity="center"
                        android:layout_alignParentTop="true">

                        <ImageView
                            android:layout_width="wrap_content"
                            android:layout_gravity="center_vertical"
                            android:layout_height="match_parent"
                            android:tint="@color/white"
                            android:layout_margin="4dp"
                            android:src="@drawable/draw"/>

                    </LinearLayout>

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentBottom="true"
                        android:id="@+id/tvDraw"
                        android:text="@string/draw"
                        android:layout_centerHorizontal="true"
                        android:textColor="@color/white"
                        android:background="@color/red"
                        android:gravity="center"
                        android:padding="8dp"
                        android:textStyle="bold"/>

                </RelativeLayout>

                <RelativeLayout
                    android:id="@+id/rlTeams"
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_marginTop="8dp"
                    android:layout_marginBottom="8dp"
                    android:background="@color/top_blue"
                    android:layout_marginStart="4dp"
                    android:layout_marginEnd="4dp"
                    android:layout_height="wrap_content">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_above="@+id/tvSupport"
                        android:gravity="center"
                        android:layout_alignParentTop="true">

                        <ImageView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:id="@+id/ivSupport"
                            android:tint="@color/white"
                            android:src="@drawable/team_land" />

                    </LinearLayout>

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentBottom="true"
                        android:text="@string/support_team"
                        android:id="@+id/tvSupport"
                        android:layout_centerHorizontal="true"
                        android:textColor="@color/white"
                        android:background="@color/red"
                        android:gravity="center"
                        android:padding="8dp"
                        android:textStyle="bold"/>
                </RelativeLayout>
            </LinearLayout>


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:layout_weight="1"
                android:layout_marginTop="4dp"
                android:layout_marginStart="32dp"
                android:layout_marginEnd="32dp"
                android:layout_marginBottom="4dp"
                android:orientation="horizontal">

                <RelativeLayout
                    android:id="@+id/rlResults"
                    android:layout_width="0dp"
                    android:background="@color/top_blue"
                    android:layout_weight="1"
                    android:layout_marginTop="8dp"
                    android:layout_marginBottom="8dp"
                    android:layout_marginStart="4dp"
                    android:layout_marginEnd="4dp"
                    android:layout_height="wrap_content">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_above="@+id/tvResults"
                        android:gravity="center"
                        android:layout_alignParentTop="true">

                        <ImageView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:src="@drawable/results" />

                    </LinearLayout>

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentBottom="true"
                        android:text="@string/clouds_results"
                        android:layout_centerHorizontal="true"
                        android:textColor="@color/white"
                        android:id="@+id/tvResults"
                        android:background="@color/red"
                        android:gravity="center"
                        android:padding="8dp"
                        android:textStyle="bold"/>
                </RelativeLayout>

                <RelativeLayout
                    android:id="@+id/rlNews"
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:background="@color/top_blue"
                    android:layout_marginTop="8dp"
                    android:layout_marginBottom="8dp"
                    android:layout_marginStart="4dp"
                    android:layout_marginEnd="4dp"
                    android:layout_height="wrap_content">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_above="@+id/tvNews"
                        android:gravity="center"
                        android:layout_alignParentTop="true">

                        <ImageView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:src="@drawable/news" />

                    </LinearLayout>

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_alignParentBottom="true"
                        android:text="@string/news"
                        android:layout_centerHorizontal="true"
                        android:textColor="@color/white"
                        android:id="@+id/tvNews"
                        android:background="@color/red"
                        android:gravity="center"
                        android:padding="8dp"
                        android:textStyle="bold"/>
                </RelativeLayout>
            </LinearLayout>

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginStart="32dp"
            android:layout_weight="6"
            android:layout_marginEnd="32dp"
            android:layout_marginTop="12dp"
            android:orientation="horizontal">

            <RelativeLayout
                android:id="@+id/rlRating"
                android:layout_width="match_parent"
                android:background="@color/top_blue"
                android:layout_marginTop="8dp"
                android:layout_marginBottom="32dp"
                android:layout_marginStart="4dp"
                android:layout_marginEnd="4dp"
                android:layout_height="wrap_content">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_above="@+id/tvMyRating"
                    android:gravity="center"
                    android:layout_alignParentTop="true">

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_gravity="center_vertical"
                        android:layout_height="wrap_content"
                        android:tint="@color/white"
                        android:layout_margin="4dp"
                        android:src="@drawable/star"/>

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_gravity="center_vertical"
                        android:tint="@color/white"
                        android:layout_height="wrap_content"
                        android:layout_margin="4dp"
                        android:src="@drawable/star"/>

                    <ImageView
                        android:layout_width="wrap_content"
                        android:layout_gravity="center_vertical"
                        android:tint="@color/white"
                        android:layout_margin="4dp"
                        android:layout_height="wrap_content"
                        android:src="@drawable/star"/>

                </LinearLayout>

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/tvMyRating"
                    android:layout_alignParentBottom="true"
                    android:text="@string/my_rating"
                    android:layout_centerHorizontal="true"
                    android:textColor="@color/white"
                    android:background="@color/red"
                    android:gravity="center"
                    android:padding="8dp"
                    android:textStyle="bold"/>
            </RelativeLayout>
        </LinearLayout>

    </LinearLayout>

</RelativeLayout>

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:paddingTop="10dp"
    android:layout_gravity="start"
    android:fitsSystemWindows="true">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="10dp"
        android:background="@color/blue"
        android:orientation="vertical">


        <ListView
            android:id="@+id/lst_menu_items"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:background="@color/blue"
            android:divider="@android:color/transparent"
            android:paddingTop="5dp" />
    </LinearLayout>

</android.support.design.widget.NavigationView>

这是所需的设计 needed design

这是我的布局 my layout

2 个答案:

答案 0 :(得分:1)

尝试

<color name="top_blue">#CC284575</color>

CC表示80%不透明。有关详细信息,请参阅此answer

答案 1 :(得分:0)

十六进制不透明度值

100% - FF 95% - F2 90% - E6 85% - D9 80% - CC 75% - 高炉 70% - B3 65% - A6 60% - 99 55% - 8C 50% - 80 45% - 73 40% - 66 35% - 59 30% - 4D 25% - 40 20% - 33 15% - 26 10% - 1A 5% - 0D 0% - 00

  tableView.sectionIndexBackgroundColor = UIColor(white: CGFloat(1.0), alpha: CGFloat(0.5)) // change the alpha and check once