Android:fill_parent和wrap_内容不会在所有设备上填满全屏
好的,我了解所有高密度的手机和屏幕,我的问题是为什么我的背景色不能填满整个页面?在我的平板电脑上,它只是一个背景色的小盒子,其余的只是块背景。请帮忙 附加问题:对于高密度手机,这是否意味着我必须制作3张不同的图像,然后将它们放在不同的文件夹中,或者我可以只制作1张图像,然后将它们放在文件夹中,然后应用程序将处理所有其他事情?我真的不知道我是否控制了图像质量/分辨率,应用程序是否选择了哪一个,或者应用程序是否会自动将图像更改为正确的分辨率和大小 活动文件:Android:fill_parent和wrap_内容不会在所有设备上填满全屏,android,size,screen,Android,Size,Screen,好的,我了解所有高密度的手机和屏幕,我的问题是为什么我的背景色不能填满整个页面?在我的平板电脑上,它只是一个背景色的小盒子,其余的只是块背景。请帮忙 附加问题:对于高密度手机,这是否意味着我必须制作3张不同的图像,然后将它们放在不同的文件夹中,或者我可以只制作1张图像,然后将它们放在文件夹中,然后应用程序将处理所有其他事情?我真的不知道我是否控制了图像质量/分辨率,应用程序是否选择了哪一个,或者应用程序是否会自动将图像更改为正确的分辨率和大小 活动文件: package u.nav.it; i
package u.nav.it;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
public class UNavitActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
}
}
自定义标题.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:background="#62CFD2"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:src="@drawable/selectiontitle"/>
</RelativeLayout>
自定义样式.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CustomWindowTitleBackground">
<item name="android:background">#323331</item>
</style>
<style name="CustomTheme" parent="android:Theme">
<item name="android:windowTitleSize">50dp</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
</style>
</resources>
#323331
50dp
@样式/自定义窗口标题背景
main.xml:
<?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" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
</LinearLayout>
舱单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="u.nav.it"
android:versionCode="1"
android:versionName="1.0" >
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".UNavitActivity" android:theme="@style/CustomTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
尝试使用draw9patch图像来帮助扩展未填充的空间我只需在清单中添加应用程序支持的屏幕大小。我觉得自己好笨。这并不是你问题的答案,但是,你不应该实现一个操作栏而不是一个“自定义标题”吗?你可以用它来支持大多数设备。标题栏永远只是文本(实际上是文本的图像),我不打算有任何按钮或类似的东西。它只是假设保持该颜色,然后文本可能会改变。那么动作栏真的有必要吗?你的清单中声明的最小/目标sdk是什么?我没有,它默认为15,但我在尝试安装时总是遇到解析错误,所以我删除了它,它工作正常。当然,它不是“必要的”,但它是新标准,如果你刚刚开始,不妨把它做好。特别是如果你要有一个“标题栏”之类的东西,那只会扩展我的标题图像吗?这会影响整个应用程序的背景吗?当我在main.xml中设置android:background=“color”时,为什么不将任何大小的整个屏幕设置为该颜色?