尝试通过Scroll View将我的视图调整为大屏幕和小屏幕

时间:2014-07-31 20:14:29

标签: android android-layout scrollview

这是我的问题:我试图让我的观点适应大屏幕和小屏幕。由于内容不适合小屏幕,我想到使用滚动视图来修复它。它在小屏幕上按照我的意愿工作,但每次我尝试在大屏幕上运行它时都会出错。我的布局代码:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="5dp"
    android:background="#ffffff" >

    <FrameLayout
        android:id="@+id/content_frame2"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

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

            <com.google.android.gms.ads.AdView
                xmlns:ads="http://schemas.android.com/apk/res-auto"
                android:id="@+id/adView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                ads:adUnitId="ca-app-pub-7098126077977688/3494300657"
                ads:adSize="BANNER"
                android:layout_gravity="center"/>

            <ScrollView 
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >

                    <ImageView 
                        android:id="@+id/ad_view_photo_image"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_gravity="center"/>

                    <TextView
                        android:id="@+id/ad_view_description"
                        android:text="TextView"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:padding="5dp"
                        android:layout_gravity="center" />

                    <TextView
                        android:id="@+id/ad_view_price"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Large Text"
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:padding="5dp"
                        android:layout_gravity="center" />

                    <Button
                        android:id="@+id/ad_view_buy"
                        android:text="Comprar"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:padding="5dp"
                        android:layout_gravity="center" />

                    <Button
                        android:id="@+id/ad_view_back"
                        android:text="Voltar"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:padding="5dp"
                        android:layout_gravity="center" />

                </LinearLayout>

            </ScrollView>

        </LinearLayout>

    </FrameLayout>

    <include layout="@layout/drawer"/>

</android.support.v4.widget.DrawerLayout>

和错误:

活动已泄露窗口

可以有人给我一些帮助吗?谢谢!

1 个答案:

答案 0 :(得分:0)

好吧,我刚刚解决了这个问题,这是我的异步任务中的一个问题,因为某些原因在我的小屏幕模拟器中测试应用程序时没有发生。我试图修改异步任务中主线程创建的视图。