在android中,如何使布局适合屏幕,而无需左右角的空间
在我的布局中,我得到了空间左边距和右边距,但我需要适合屏幕,我不需要左边距和右边距,在我的代码下面的一些布局中,任何人请帮助我 XML 我需要两个布局适合屏幕没有任何空间在左边距和右边距我的最后两个布局任何一个请帮助我如何得到这个在android中,如何使布局适合屏幕,而无需左右角的空间,android,android-linearlayout,Android,Android Linearlayout,在我的布局中,我得到了空间左边距和右边距,但我需要适合屏幕,我不需要左边距和右边距,在我的代码下面的一些布局中,任何人请帮助我 XML 我需要两个布局适合屏幕没有任何空间在左边距和右边距我的最后两个布局任何一个请帮助我如何得到这个 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="m
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_marginTop="20dp"
android:background="@drawable/un_named"
android:weightSum="1">
<LinearLayout
android:layout_marginTop="110dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#FFFFFF">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="120dp"
android:layout_height="160dp"
android:id="@+id/imageview_text"
android:layout_weight="0"
android:padding="10dp"
android:src="@drawable/un_named"/>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="3">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv01"
android:textSize="18dp"
android:padding="10dp"
android:textStyle="bold"
android:text="Moviewheewd ewudwd wedewd w"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv02"
android:paddingLeft="10dp"
android:text=" wjh wd wed we dtext"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv03"
android:paddingLeft="10dp"
android:text="simple text"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv04"
android:paddingLeft="10dp"
android:text="simple jwehd wj dewjd"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv07"
android:paddingLeft="10dp"
android:text="simple heds xaks katext"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="10dp"
android:background="#00FFFFFF" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="40dp"
android:orientation="horizontal">
<Button
android:id="@+id/btun1"
android:text="hello"
android:layout_width="184dp"
android:gravity="center"
android:textSize="20dp"
android:layout_height="40dp"
android:background="#4DFFFFFF"/>
<Button
android:id="@+id/butn2"
android:layout_marginLeft="10dp"
android:text="hello world"
android:textSize="20dp"
android:drawableRight="@drawable/down"
android:gravity="center"
android:layout_width="184dp"
android:layout_height="40dp"
android:background="#4DFFFFFF"/>
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="10dp"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF">
<TextView
android:id="@+id/textreview_dec"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="fs dsfjsdf sjf ds fds fsd fds fds fs fmdmsn fsm fsm fsm fdsm f
hdfbsd fsdjfhsd dfdsj fsd fdsj fds fds fdsj fsd df
fsdfhsd dfjsd fhds fjs fds fjds dfs
dskjfsd fsd fs dfsd dfsd fs dfksd fkds fkds fdks fdsk fdsk f
f skdf sk fksd fksd fdsk fsk f f ff df
f skf skf ksdf fsk fkdfdkdf ksf
fks fsk dk fks fdks fdksf sk f
f skdf skf ksf skdf dsf df dskf kdf kds
f ksd fdksf dskf df dskf dskf dsk f dsk f
fksf s fksd "/>
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="10dp"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="245dp"
android:background="#FFFFFF">
<TextView
android:layout_marginLeft="10dp"
android:gravity="center_vertical"
android:text="Video"
android:layout_width="fill_parent"
android:layout_height="35dp"
android:textStyle="bold"
android:textSize="15dp"/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="183dp"
android:id="@+id/imageView2"
android:src="@drawable/imginews"
android:scaleType="fitXY"
/></LinearLayout>
</LinearLayout>
您的答案-最后两个线性布局,没有任何左右填充
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:background="@drawable/un_named"
android:weightSum="1">
<LinearLayout
android:layout_marginTop="110dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:orientation="horizontal"
android:background="#FFFFFF">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="120dp"
android:layout_height="160dp"
android:id="@+id/imageview_text"
android:layout_weight="0"
android:padding="10dp"
android:src="@drawable/un_named"/>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="3">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv01"
android:textSize="18dp"
android:padding="10dp"
android:textStyle="bold"
android:text="Moviewheewd ewudwd wedewd w"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv02"
android:paddingLeft="10dp"
android:text=" wjh wd wed we dtext"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv03"
android:paddingLeft="10dp"
android:text="simple text"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv04"
android:paddingLeft="10dp"
android:text="simple jwehd wj dewjd"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv07"
android:paddingLeft="10dp"
android:text="simple heds xaks katext"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="10dp"
android:background="#00FFFFFF" />
<LinearLayout
android:layout_width="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_height="40dp"
android:orientation="horizontal">
<Button
android:id="@+id/btun1"
android:text="hello"
android:layout_width="184dp"
android:gravity="center"
android:textSize="20dp"
android:layout_height="40dp"
android:background="#4DFFFFFF"/>
<Button
android:id="@+id/butn2"
android:layout_marginLeft="10dp"
android:text="hello world"
android:textSize="20dp"
android:drawableRight="@drawable/down"
android:gravity="center"
android:layout_width="184dp"
android:layout_height="40dp"
android:background="#4DFFFFFF"/>
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="10dp"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF">
<TextView
android:id="@+id/textreview_dec"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="fs dsfjsdf sjf ds fds fsd fds fds fs fmdmsn fsm fsm fsm fdsm f
hdfbsd fsdjfhsd dfdsj fsd fdsj fds fds fdsj fsd df
fsdfhsd dfjsd fhds fjs fds fjds dfs
dskjfsd fsd fs dfsd dfsd fs dfksd fkds fkds fdks fdsk fdsk f
f skdf sk fksd fksd fdsk fsk f f ff df
f skf skf ksdf fsk fkdfdkdf ksf
fks fsk dk fks fdks fdksf sk f
f skdf skf ksf skdf dsf df dskf kdf kds
f ksd fdksf dskf df dskf dskf dsk f dsk f
fksf s fksd "/>
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="10dp"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="245dp"
android:background="#FFFFFF">
<TextView
android:layout_marginLeft="10dp"
android:gravity="center_vertical"
android:text="Video"
android:layout_width="fill_parent"
android:layout_height="35dp"
android:textStyle="bold"
android:textSize="15dp"/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="183dp"
android:id="@+id/imageView2"
android:src="@drawable/imginews"
android:scaleType="fitXY"
/></LinearLayout>
使用此代码并再次替换图像。
我希望这将对您有所帮助。从根目录中删除
paddingLeft
和paddingRight
,但在我的第一个布局中,我需要左空格和灯光,然后只在第一个布局中添加填充。小部件(TextView,ImageView)删除填充android:paddingLeft=“10dp”我把他们的空间,但不是getting@camelCaseCoderfirstLayout没有足够的空间Right@Rakesh
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="horizontal" >
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/imageview_text"
android:layout_width="120dp"
android:layout_height="160dp"
android:layout_weight="0"
android:padding="10dp"
android:src="@drawable/ic_launcher" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical" >
<TextView
android:id="@+id/tv01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Moviewheewd ewudwd wedewd w"
android:textSize="18dp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text=" wjh wd wed we dtext" />
<TextView
android:id="@+id/tv03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="simple text" />
<TextView
android:id="@+id/tv04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="simple jwehd wj dewjd
" />
<TextView
android:id="@+id/tv07"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="simple heds xaks katext" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="10dp"
android:background="#00FFFFFF" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="40dp"
android:orientation="horizontal"
android:weightSum="2">
<Button
android:id="@+id/btun1"
android:layout_width="184dp"
android:layout_height="40dp"
android:layout_weight="1"
android:background="#4DFFFFFF"
android:gravity="center"
android:text="hello"
android:textSize="20dp" />
<Button
android:id="@+id/butn2"
android:layout_width="184dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:background="#4DFFFFFF"
android:drawableRight="@drawable/cast_ic_notification_1"
android:gravity="center"
android:text="hello world"
android:layout_weight="1"
android:textSize="20dp" />
</LinearLayout>
<View
android:layout_width="wrap_content"
android:layout_height="10dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF" >
<TextView
android:id="@+id/textreview_dec"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="fs dsfjsdf sjf ds fds fsd fds fds fs fmdmsn fsm fsm fsm fdsm f
hdfbsd fsdjfhsd dfdsj fsd fdsj fds fds fdsj fsd df
f ksd fdksf dskf df dskf dskf dsk f dsk f
fksf s fksd " />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="35dp"
android:gravity="center_vertical"
android:text="Video"
android:textSize="15dp"
android:textStyle="bold" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="fill_parent"
android:layout_height="183dp"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher" />
</LinearLayout>