我使用自定义布局来显示首选项,以便我可以在屏幕底部插入广告条。这个想法是让横幅贴在页面的底部,并在滚动视图中显示屏幕的其余部分。 我的偏好设置的高度有问题。 我目前在下面的XML布局中将其硬编码为“2000dip”。Android:自定义首选项屏幕大小问题
它工作正常,横幅停留在底部,在可滚动视图顶部的喜好。
但是,硬编码的高度值不好,我希望它自动设置为偏好所采用的确切高度,因为它目前太短或太长(在偏好之后有空白区域)。 我试图用wrap_content或fill_parent替换硬编码值,但没有成功。 有什么想法?
在我PreferenceActivity我已经包含以下两行:
setContentView(R.layout.preferences_scrollable);
addPreferencesFromResource(R.layout.preferences);
而且我定义的XML文件preferences_scrollable.xml布局preferences_scrollable:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<ScrollView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_weight="1"
android:id="@+id/pref_scrollable_sv">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="vertical"
android:id="@+id/pref_scrollable_ll">
<ListView android:id="@android:id/list"
android:layout_width="fill_parent" android:layout_height="2000dip">
</ListView>
</LinearLayout>
</ScrollView>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="vertical">
<com.google.ads.AdView android:id="@+id/ad"
ads:adSize="BANNER" android:layout_width="fill_parent"
ads:loadAdOnCreate="true" ads:adUnitId="xxx"
android:layout_height="wrap_content"
android:layout_weight="0"/>
</LinearLayout>
</LinearLayout>
nope,没有做任何事情...... – muslidrikk