Android版式中屏幕外的元素 [英] Elements out of screen in Android Layout
本文介绍了Android版式中屏幕外的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在处理Android的列表视图布局.下图是我想要的样子.
I'm currently working on a listview layout for Android. The following picture is how I want it to look.
...这是我的代码.
...and this is my code.
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:background="@drawable/list_selector"
android:orientation="horizontal">
<TextView
android:id="@+id/textView2"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:ellipsize="end"
android:text=""
android:textSize="10sp"
android:textColor="@color/light_black"
android:maxLines="2" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginLeft="5dp"
android:contentDescription="" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:orientation="horizontal"
android:gravity="center_horizontal">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_gravity="center"
android:text=""
android:textSize="13sp"
android:textColor="@color/black"/>
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="4dp"
android:text="@string/versus"
android:textSize="10sp"
android:textColor="@color/black"/>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_gravity="center"
android:text=""
android:textSize="13sp"
android:textColor="@color/black"/>
</LinearLayout>
<ImageView
android:id="@+id/imageView3"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_gravity="right" />
...这就是我得到的结果
...and this is the result I get
您知道为什么第二个团队徽标未显示在屏幕上吗?我已经尝试过将其放在单独的linearlayout中,但是没有用.
Do you have any idea why the second team logo is not showing on the screen. I already tried to put it in separate linearlayout but It did not work.
推荐答案
这是因为您的内部<LinearLayout>
正在使用android:layout_width="match_parent"
.要使其不占据所有空间,您还需要设置其layout_weight
:
It's becasue your internal <LinearLayout>
is using android:layout_width="match_parent"
. To make it not occupy all the space you need to set its layout_weight
too:
android:layout_weight="1"
这篇关于Android版式中屏幕外的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文