[英]fill_parent is not filling entire screen in LinearLayout
I tried to search for this answer and the closest I got to an answer was to add android:resizable="true", which is deprecated. 我试图搜索此答案,而我最接近答案的是添加android:resizable =“ true”,该名称已弃用。 I apologize if this question has been answered but I couldn't find it if it was. 如果这个问题已得到解答,我深表歉意,但如果找到,我找不到。
Anyway, my app is not filling the entire screen. 无论如何,我的应用程序无法充满整个屏幕。 The method I was using was working in android 2.2 but I am now using a 2.3 emulator and it's not working. 我使用的方法在android 2.2中有效,但是我现在使用的是2.3模拟器,它不起作用。 I am not sure if this is actually the issue or not. 我不确定这是否是问题所在。
Now to the problem... 现在解决问题...
I am creating a temperature converter app (yes, it's homework) and the app is not filling the entire screen even though I say fill_parent for the layout_width and height in the LinearLayout. 我正在创建一个温度转换器应用程序(是的,这是家庭作业),即使我为LinearLayout中的layout_width和height说fill_parent,该应用程序也无法填充整个屏幕。 A suggestion I saw was to use a RelativeLayout, which I could do I suppose but it seems like a band-aid, not a solution. 我看到的建议是使用RelativeLayout,我可以做到这一点,但这似乎是一个创可贴,而不是解决方案。 Shouldn't this work? 这不行吗?
Here is my code: 这是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical"
android:background="@color/white"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Temperature Converter"
android:textColor="@color/black"
/>
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/convertGroup"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<RadioButton android:id="@+id/CtoF"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Celsius to Fahrenheit"
android:textColor="@color/black"
/>
<RadioButton android:id="@+id/FtoC"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Fahrenheit to Celsius"
android:textColor="@color/black"
/>
</RadioGroup>
<EditText
android:id="@+id/tempInput"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:hint="Temperature"
/>
<TextView
android:id="@+id/converted"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/black"
/>
</LinearLayout>
Here is the result: 结果如下:
Add below code in menifest after application tag 在应用程序标记后的清单中添加以下代码
<supports-screens android:resizeable="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="true" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.