Android textview不适合所有屏幕

时间:2021-12-17 21:13:44

i developed one of application and now am facing problem that it show perfectly in my nexus7 but when i viewing other device screens the text view not fitting i want all the screen as same as nexus7. its anyone can know the better solution for this please. unfortunately i don't have enough reputation so i cant post any screenshot here this my xml code

我开发了一个应用程序,现在面临的问题,它在我的nexus7中完美显示,但当我查看其他设备屏幕时,文本视图不适合我希望所有屏幕与nexus7相同。它的任何人都可以知道更好的解决方案。不幸的是我没有足够的声誉所以我不能在这里发布任何截图这个我的xml代码

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
 android:layout_gravity="center"
android:background="@color/white">

 <RelativeLayout
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:gravity="center"
 android:paddingBottom="16dp"
 android:paddingLeft="64dp"
 android:paddingRight="64dp"
 android:paddingTop="16dp" >

 <ImageView
    android:id="@+id/pointer"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_centerInParent="true"
    android:src="@drawable/point" />

 </RelativeLayout>

   <RelativeLayout
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:gravity="bottom"
 android:paddingBottom="16dp"
 android:paddingLeft="64dp"
 android:paddingRight="64dp"
 android:paddingTop="16dp" >

        <TextView
            android:id="@+id/name2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="97dp"
            android:text="@string/numberusers"
            android:textColor="@color/no_users"
            android:textSize="30sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="19dp"
            android:text="@string/number"
            android:textColor="@color/no_users"
            android:textSize="30sp"
            android:textStyle="bold" />

 <RelativeLayout
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:gravity="center"
     android:paddingBottom="16dp"
     android:paddingLeft="64dp"
     android:paddingRight="64dp"
     android:paddingTop="355dp" >

        <ListView
            android:id="@android:id/list"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_gravity="center_horizontal"
            android:clickable="false" >

        </ListView>

     </RelativeLayout>

    </RelativeLayout>
   </RelativeLayout>

4 个解决方案

#1


0  

I m Not Sure But Remove Relative Layout And Use Linear Layout Its More Better Than Relative

我不确定但删除相对布局并使用线性布局它比相对更好

#2


0  

The two textViews that you have in your layout use android:layout_width="wrap_content".

您在布局中使用的两个textView使用android:layout_width =“wrap_content”。

Use android:layout_width="match_parent" in the one you want to fill the screen.

在要填充屏幕的那个中使用android:layout_width =“match_parent”。

#3


0  

every children relative layout in your xml has height and width as match_parent. Do you need it? Because if first layout have height as match_arent than it will not leave space for others. Try using "wrap_content" as height for inner relative layouts.

xml中的每个子相对布局都具有match_parent的高度和宽度。你需要它吗?因为如果第一个布局的高度为match_arent,则不会为其他布局留出空间。尝试使用“wrap_content”作为内部相对布局的高度。

#4


0  

If I got your question, you have to set the width of the textview as

如果我收到你的问题,你必须将textview的宽度设置为

android:layout_width="match_parent" 

But in my opinion, the hole screen is wrong. Use a LinearLayout (vertical or horizontal) and place there your first two textviews. And if you want more accuracy use the gravity feature in each text view and of course set a layout_weight for each TextView and weightSum in the LinearLayout.

但在我看来,洞屏幕是错误的。使用LinearLayout(垂直或水平)并将前两个文本视图放在那里。如果您想要更高的精确度,请在每个文本视图中使用重力特征,当然还要为LinearLayout中的每个TextView和weightSum设置layout_weight。

#1


0  

I m Not Sure But Remove Relative Layout And Use Linear Layout Its More Better Than Relative

我不确定但删除相对布局并使用线性布局它比相对更好

#2


0  

The two textViews that you have in your layout use android:layout_width="wrap_content".

您在布局中使用的两个textView使用android:layout_width =“wrap_content”。

Use android:layout_width="match_parent" in the one you want to fill the screen.

在要填充屏幕的那个中使用android:layout_width =“match_parent”。

#3


0  

every children relative layout in your xml has height and width as match_parent. Do you need it? Because if first layout have height as match_arent than it will not leave space for others. Try using "wrap_content" as height for inner relative layouts.

xml中的每个子相对布局都具有match_parent的高度和宽度。你需要它吗?因为如果第一个布局的高度为match_arent,则不会为其他布局留出空间。尝试使用“wrap_content”作为内部相对布局的高度。

#4


0  

If I got your question, you have to set the width of the textview as

如果我收到你的问题,你必须将textview的宽度设置为

android:layout_width="match_parent" 

But in my opinion, the hole screen is wrong. Use a LinearLayout (vertical or horizontal) and place there your first two textviews. And if you want more accuracy use the gravity feature in each text view and of course set a layout_weight for each TextView and weightSum in the LinearLayout.

但在我看来,洞屏幕是错误的。使用LinearLayout(垂直或水平)并将前两个文本视图放在那里。如果您想要更高的精确度,请在每个文本视图中使用重力特征,当然还要为LinearLayout中的每个TextView和weightSum设置layout_weight。