如何编辑布局到全屏?

时间:2016-08-14 03:23:45

标签: android eclipse android-layout android-linearlayout relativelayout

我有一个应用程序,其中包含一个主RelativeLayout和一些LinearLayout。 我的问题是LinearLayout不适合屏幕的整个长度: 这是我的xml文件:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/bgApp" >

<LinearLayout
    android:id="@+id/mainView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="@dimen/topBarHeight"
            android:background="@drawable/top"
            android:gravity="center"
            android:orientation="vertical" >

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center_vertical"
                android:orientation="horizontal"
                android:background="@android:color/transparent" >

                <ImageView
                    android:id="@+id/scoreLogo"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@drawable/coin_icon" 
                    android:contentDescription="@string/app_name"/>

                <TextView
                    android:id="@+id/mainScreenTotalPoints"
                    style="@style/pointTxt"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingLeft="@dimen/btnPaddingV"
                    android:text="@string/startPoint"
                    android:textSize="@dimen/buttonTextSize" />
            </LinearLayout>
        </LinearLayout>

        <TextView
            android:id="@+id/logo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginBottom="@dimen/logPadding"
            android:text="@string/app_name"
            android:textColor="#d0105e"
            android:textSize="27sp"
            android:textStyle="bold"/>

        <LinearLayout
            android:id="@+id/root"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:paddingLeft="@dimen/btnPadding"
            android:paddingRight="@dimen/btnPadding" >

            <Button
                android:id="@+id/play"
                android:layout_width="fill_parent"
                android:layout_height="@dimen/buttonHeight"
                android:background="@drawable/button_blue"
                android:gravity="center"
                android:onClick="onButtonClickPlay"
                android:text="@string/play"
                android:textColor="@color/btnMain"
                android:textSize="@dimen/buttonTextSize" />

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:gravity="bottom"
                android:orientation="vertical"
                android:paddingTop="@dimen/mainbox" >

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:paddingBottom="@dimen/btnPadding" >

                    <Button
                        android:id="@+id/btn_how"
                        style="@style/btnCapital"
                        android:layout_width="fill_parent"
                        android:layout_height="@dimen/buttonHeight"
                        android:layout_marginRight="@dimen/btnPaddingV"
                        android:layout_weight="1.0"
                        android:background="@drawable/button_green_how"
                        android:onClick="onButtonClickHowToPlay"
                        android:text="@string/howInfo" />

                    <Button
                        android:id="@+id/btn_rate"
                        style="@style/btnCapital"
                        android:layout_width="fill_parent"
                        android:layout_height="@dimen/buttonHeight"
                        android:layout_marginLeft="@dimen/btnPaddingV"
                        android:layout_weight="1.0"
                        android:background="@drawable/button_rate"
                        android:onClick="onButtonClickRate"
                        android:text="@string/rateInfo" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:paddingBottom="@dimen/btnPadding" >

                    <Button
                        android:id="@+id/sound"
                        style="@style/btnCapital"
                        android:layout_width="0dp"
                        android:layout_height="@dimen/buttonHeight"
                        android:layout_marginTop="1.0dip"
                        android:layout_weight="1.0"
                        android:background="@drawable/mute_01"
                        android:gravity="center"
                        android:onClick="onButtonClickSound"
                        android:text="@string/mute" />


                </LinearLayout>

                 <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:paddingBottom="@dimen/btnPadding" >

                    <Button
                        android:id="@+id/moreapp"
                        style="@style/btnCapital"
                        android:layout_width="0dp"
                        android:layout_height="@dimen/buttonHeight"
                        android:layout_marginTop="1.0dip"
                        android:layout_weight="1.0"
                        android:background="@drawable/button_blue"
                        android:gravity="center"
                        android:onClick="onButtonClickMoreApp"
                        android:text="@string/moreapp" />


                </LinearLayout>
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

     <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="bottom"
        android:gravity="center"
        android:orientation="vertical" >

        <com.google.android.gms.ads.AdView
            android:id="@+id/adView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="bottom"
            ads:adSize="BANNER"
            ads:adUnitId="@string/admob_publisher_id"
            android:gravity="bottom" />
    </LinearLayout> 
</LinearLayout>

</ScrollView>

这是一个截图: Screenshot after running app

这里是运行app之前的布局截图: Screenshot before running app

提前谢谢!

2 个答案:

答案 0 :(得分:0)

您需要使用名为SELECT dt, DAYNAME(dt) as day FROM myTable WHERE dt BETWEEN date1 AND date2 ORDER BY dt WHERE day = "Sunday" LIMIT 0,1 的ScrollView属性。如果需要,此属性会使滚动视图的子项扩展到ScrollView的高度。

当孩子比ScrollView高时,该属性无效。

查看this了解详细说明。

答案 1 :(得分:0)

你必须在你的滚动视图中使用属性android:fillViewport =“true”。

相关问题