下面我为android写的代码,但这个设计并不适合所有的android屏幕
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:scrollbarStyle="insideOverlay"
>
<LinearLayout
android:id="@+id/layout_status"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/wight"
android:baselineAligned="false"
android:orientation="vertical" >
<TextView
android:id="@+id/tseriesname"
android:layout_width="fill_parent"
android:layout_height="20dp"
android:layout_margin="5dp"
android:gravity="center"
android:singleLine="true"
android:text="@string/series_name"
android:textColor="@color/textgraycolor"
android:textSize="10.0sp"
android:textStyle="bold" />
<Button
android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_gravity="center"
android:layout_marginBottom="5dp"
android:background="@drawable/list_border_back_red"
android:text="Live"
android:textColor="@android:color/white"
android:textSize="15.0sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout_match"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/layout_status"
android:layout_weight="0.14"
android:background="@color/wight"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="5dp" >
<LinearLayout
android:layout_width="65dp"
android:layout_height="90dp"
android:layout_gravity="center_vertical"
android:orientation="vertical" >
<ImageView
android:id="@+id/flag_team1"
android:layout_width="65dp"
android:layout_height="65dp"
android:src="@drawable/flag1" />
<TextView
android:id="@+id/team_name1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="center"
android:text="KKR"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout_score_team1"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.32"
android:background="@color/wight"
android:baselineAligned="true"
android:orientation="vertical" >
<TextView
android:id="@+id/score_team1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="left|center_vertical"
android:text="160/3"
android:textColor="@color/txtscore"
android:textSize="25sp"
android:textStyle="bold" />
<TextView
android:id="@+id/over_tem1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="left"
android:text="(ov : 20)"
android:textColor="@color/textgraycolor"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:id="@+id/vs"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:background="@drawable/vs"
android:gravity="center_horizontal|center_vertical"
android:text="@string/vs"
android:textColor="@color/wight"
android:textSize="15sp"
android:textStyle="bold" />
<LinearLayout
android:id="@+id/layout_score_team2"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="0.32"
android:background="@color/wight"
android:baselineAligned="true"
android:orientation="vertical" >
<TextView
android:id="@+id/score_team2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="right"
android:text="140/2 "
android:textColor="@color/txtscore"
android:textSize="25sp"
android:textStyle="bold" />
<TextView
android:id="@+id/over_tem2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="right"
android:text="(ov: 18.3 )"
android:textColor="@color/textgraycolor"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="65dp"
android:layout_height="90dp"
android:layout_gravity="center_vertical"
android:orientation="vertical" >
<ImageView
android:id="@+id/flag_team2"
android:layout_width="65dp"
android:layout_height="65dp"
android:src="@drawable/flag2" />
<TextView
android:id="@+id/team_name2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="center"
android:text="MI"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/layout_over_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/layout_match"
android:layout_centerHorizontal="true"
android:layout_margin="10dp"
android:layout_weight="0.16"
android:background="@color/wight"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:id="@+id/re_rr"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="left"
android:layout_marginLeft="10dp"
android:background="@android:color/white"
android:gravity="left"
android:text="Required RR : 2.56"
android:textColor="@android:color/black"
android:textSize="10sp"
android:textStyle="bold" />
<TextView
android:id="@+id/cu_rr"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right"
android:layout_marginRight="10dp"
android:layout_weight="0.15"
android:background="@android:color/white"
android:gravity="right"
android:text="Current RR: 5.36"
android:textColor="@android:color/black"
android:textSize="10sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center_vertical|center_horizontal"
android:orientation="horizontal"
android:weightSum="1" >
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_margin="3dp"
android:layout_weight="0.40"
android:background="@color/wight"
android:gravity="center_vertical|center_horizontal"
android:text="OVER 19"
android:textColor="@color/txtscore"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/TextView05"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="3dp"
android:background="@drawable/roundtxt4"
android:gravity="center_vertical|center_horizontal"
android:text="4"
android:textColor="@color/wight"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/TextView04"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="3dp"
android:background="@drawable/roundtxtw"
android:gravity="center_vertical|center_horizontal"
android:text="W"
android:textColor="@color/wight"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/TextView03"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="3dp"
android:background="@drawable/roundtxtb"
android:gravity="center_vertical|center_horizontal"
android:text="NB"
android:textColor="@color/wight"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/TextView02"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="3dp"
android:background="@drawable/roundtxt6"
android:gravity="center_vertical|center_horizontal"
android:text="6"
android:textColor="@color/wight"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/TextView01"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="3dp"
android:background="@drawable/roundtxt0"
android:gravity="center_vertical|center_horizontal"
android:text="."
android:textColor="@color/wight"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/o1"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="3dp"
android:background="@drawable/roundtxt4"
android:gravity="center_vertical|center_horizontal"
android:text="4"
android:textColor="@color/wight"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Mubai Indians needed 91 runs in 9 balls to win. "
android:textColor="@android:color/black"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
<Button
android:id="@+id/button1"
android:layout_margin="10dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/layout_over_details"
android:background="@color/txt_full_score"
android:gravity="center"
android:paddingLeft="2dp"
android:text="Full ScoreBoard"
android:textColor="@color/wight"
android:textSize="20sp"
android:textStyle="bold" />
<TableLayout
android:id="@+id/batting_table"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/button1"
android:layout_weight="1"
android:background="@color/txt_full_score"
android:weightSum="1"
android:layout_margin="10dp">
<TableRow
android:id="@+id/Batting_heading_Row"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="0.40" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="@color/wight"
android:padding="1dp"
android:paddingLeft="2dp"
android:text="BATTING"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:gravity="left"
android:padding="1dp"
android:text="R"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:gravity="left"
android:padding="1dp"
android:text="B"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:gravity="left"
android:padding="1dp"
android:text="4s"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:gravity="left"
android:padding="1dp"
android:text="6s"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:gravity="left"
android:padding="1dp"
android:text="SR"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold" />
</TableRow>
<TableRow
android:id="@+id/Batting_one_row"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="0.30" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="@color/wight"
android:padding="1dp"
android:paddingLeft="2dp"
android:text="Aroan Finch"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:padding="1dp"
android:text="30"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:padding="1dp"
android:text="36"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:padding="1dp"
android:text="2"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:padding="1dp"
android:text="1"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:padding="1dp"
android:text="54.55"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
</TableRow>
<TableRow
android:id="@+id/Batting_two_row"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.30" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="@color/wight"
android:padding="1dp"
android:paddingLeft="2dp"
android:text="Rohid Sharma"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:padding="1dp"
android:text="80"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:padding="1dp"
android:text="40"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:padding="1dp"
android:text="6"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:padding="1dp"
android:text="1"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/wight"
android:padding="1dp"
android:text="101.40"
android:textColor="@color/txtscore"
android:textSize="20sp"
android:textStyle="bold" />
</TableRow>
</TableLayout>
<Button
android:id="@+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/batting_table"
android:layout_centerVertical="true"
android:background="#F44238"
android:paddingLeft="2dp"
android:text="Full Commentary"
android:textColor="@color/wight"
android:textSize="20sp"
android:textStyle="bold"
android:layout_margin="10dp"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="68.0dip"
android:layout_alignParentLeft="true"
android:layout_below="@+id/button2"
android:layout_weight="1"
android:background="@android:color/transparent"
android:gravity="center_vertical"
android:orientation="horizontal"
android:layout_margin="10dp" >
<RelativeLayout
android:layout_width="56.0dip"
android:layout_height="56.0dip" >
<TextView
android:id="@+id/image_thumbnail"
android:layout_width="48.0dip"
android:layout_height="48.0dip"
android:layout_centerInParent="true"
android:background="@color/ball6"
android:gravity="center_horizontal|center_vertical"
android:text="6"
android:textColor="@color/wight" />
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="56.0dip"
android:background="@android:color/transparent"
android:gravity="center_vertical"
android:orientation="vertical" >
<TextView
android:id="@+id/text_title"
android:layout_width="fill_parent"
android:layout_height="69dp"
android:layout_marginLeft="6.0dip"
android:paddingBottom="2dp"
android:scrollbars="vertical"
android:singleLine="false"
android:text="David Warner and Joe Burns started off positively and added 49 runs before the former was caught behind when he gloved one off Wagner. Khawaja and Burns then made sure Australia don't lose any further wickets and negotiated the last few overs."
android:textColor="@color/txtscore"
android:textSize="13.0sp" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
答案 0 :(得分:4)
您在xml中使用自定义android:layout_width
和android:layout_height
属性,因此在具有不同屏幕尺寸的不同设备中将以不同的方式查看此xml代码。
我建议您学习以下开发人员文档:
答案 1 :(得分:2)
您可以使用ScrollView
,也可以针对不同的布局尺寸使用不同的文件夹 -
layout-ldpi (Low DPI phones)
layout-mdpi (Medium DPI phones)
layout-hdpi (High DPI phones)
layout-xhdpi (Very High DPI phones)
layout-xxhdpi (Very Very High DPI phones)
如果您使用的是Android Studio,它会自动判断哪种DPI适合哪种屏幕尺寸。
答案 2 :(得分:2)
wrap_content
。drawable-hdpi
,drawable-mdpi
,drawable-xdpi
,drawable-xxdpi
。TextView
将来价值很高,请尝试将其保持在单行中。LinearLayout
用于视图的主分区。使用weightsum
可以帮助您处理更复杂的情况。dimen.xml
作为文字大小。答案 3 :(得分:1)
由于您在dp中使用静态高度和重量,
你应该为多种屏幕尺寸定义这样的东西:
在值文件夹中:
dimen.xml文件:
<!-- Margins -->
<dimen name="margin1">1dp</dimen>
<dimen name="margin2">2dp</dimen>
<dimen name="margin3">3dp</dimen>
<dimen name="margin5">5dp</dimen>
<dimen name="margin7">7dp</dimen>
<dimen name="margin10">10dp</dimen>
<dimen name="margin11">11dp</dimen>
<dimen name="margin13">13dp</dimen>
<dimen name="margin15">15dp</dimen>
<dimen name="margin18">18dp</dimen>
<dimen name="margin20">20dp</dimen>
<dimen name="margin25">25dp</dimen>
<dimen name="margin27">27dp</dimen>
<dimen name="margin30">30dp</dimen>
<dimen name="margin35">35dp</dimen>
<dimen name="margin40">40dp</dimen>
<dimen name="margin45">45dp</dimen>
<dimen name="margin50">50dp</dimen>
<dimen name="margin55">55dp</dimen>
<dimen name="margin60">60dp</dimen>
<dimen name="margin65">65dp</dimen>
<dimen name="margin70">70dp</dimen>
<dimen name="margin75">75dp</dimen>
<dimen name="margin80">80dp</dimen>
<dimen name="margin85">85dp</dimen>
<dimen name="margin90">90dp</dimen>
<dimen name="margin95">95dp</dimen>
<dimen name="margin100">100dp</dimen>
<!-- Text Size -->
<dimen name="text8">8sp</dimen>
<dimen name="text10">10sp</dimen>
<dimen name="text11">11sp</dimen>
<dimen name="text12">12sp</dimen>
<dimen name="text13">13sp</dimen>
<dimen name="text14">14sp</dimen>
<dimen name="text15">15sp</dimen>
<dimen name="text16">16sp</dimen>
<dimen name="text17">17sp</dimen>
<dimen name="text18">18sp</dimen>
<dimen name="text19">19sp</dimen>
<dimen name="text20">20sp</dimen>
<dimen name="text21">21sp</dimen>
<dimen name="text22">22sp</dimen>
<dimen name="text23">23sp</dimen>
<dimen name="text24">24sp</dimen>
<dimen name="text25">25sp</dimen>
<dimen name="text26">26sp</dimen>
<dimen name="text28">28sp</dimen>
<dimen name="text30">30sp</dimen>
<dimen name="text32">32sp</dimen>
<dimen name="text34">34sp</dimen>
<dimen name="text35">35sp</dimen>
<dimen name="text36">36sp</dimen>
<dimen name="text38">38sp</dimen>
<dimen name="text40">40sp</dimen>
<dimen name="text50">50sp</dimen>
<dimen name="text60">60sp</dimen>
<dimen name="text65">65sp</dimen>
<dimen name="text70">70sp</dimen>
<!-- height -->
<dimen name="height110">110dp</dimen>
<dimen name="height120">120dp</dimen>
<dimen name="height130">130dp</dimen>
<dimen name="height140">140dp</dimen>
<dimen name="height150">150dp</dimen>
<dimen name="height160">160dp</dimen>
<dimen name="height165">165dp</dimen>
<dimen name="height170">170dp</dimen>
<dimen name="height175">175dp</dimen>
<dimen name="height180">180dp</dimen>
<dimen name="height185">185dp</dimen>
<dimen name="height190">190dp</dimen>
<dimen name="height195">195dp</dimen>
<dimen name="height200">200dp</dimen>
<dimen name="height220">220dp</dimen>
<dimen name="height250">250dp</dimen>
<dimen name="height300">300dp</dimen>
<dimen name="height330">330dp</dimen>
<dimen name="height350">350dp</dimen>
<dimen name="height400">400dp</dimen>
<!-- Size -->
<dimen name="size30">30dp</dimen>
<dimen name="size35">35dp</dimen>
<dimen name="size50">50dp</dimen>
<dimen name="size75">75dp</dimen>
<dimen name="size80">80dp</dimen>
<dimen name="size100">100dp</dimen>
<dimen name="size120">120dp</dimen>
<dimen name="size130">130dp</dimen>
<dimen name="size150">150dp</dimen>
<!-- Padding -->
<dimen name="padding1">1dp</dimen>
<dimen name="padding2">2dp</dimen>
<dimen name="padding3">3dp</dimen>
<dimen name="padding4">4dp</dimen>
<dimen name="padding5">5dp</dimen>
<dimen name="padding6">6dp</dimen>
<dimen name="padding7">7dp</dimen>
<dimen name="padding8">8dp</dimen>
<dimen name="padding9">9dp</dimen>
<dimen name="padding10">10dp</dimen>
</resources>
在values-sw600dp文件夹中
维度文件:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Margins -->
<dimen name="margin1">1dp</dimen>
<dimen name="margin2">3dp</dimen>
<dimen name="margin3">5dp</dimen>
<dimen name="margin5">7dp</dimen>
<dimen name="margin7">10dp</dimen>
<dimen name="margin10">15dp</dimen>
<dimen name="margin11">16dp</dimen>
<dimen name="margin13">19dp</dimen>
<dimen name="margin15">22dp</dimen>
<dimen name="margin18">27dp</dimen>
<dimen name="margin20">30dp</dimen>
<dimen name="margin25">32dp</dimen>
<dimen name="margin27">40dp</dimen>
<dimen name="margin30">45dp</dimen>
<dimen name="margin35">47dp</dimen>
<dimen name="margin40">60dp</dimen>
<dimen name="margin45">62dp</dimen>
<dimen name="margin50">75dp</dimen>
<dimen name="margin55">85dp</dimen>
<dimen name="margin60">90dp</dimen>
<dimen name="margin65">97dp</dimen>
<dimen name="margin70">105dp</dimen>
<dimen name="margin75">110dp</dimen>
<dimen name="margin80">120dp</dimen>
<dimen name="margin85">127dp</dimen>
<dimen name="margin90">135dp</dimen>
<dimen name="margin95">142dp</dimen>
<dimen name="margin100">150dp</dimen>
<!-- Text Size -->
<dimen name="text8">12sp</dimen>
<dimen name="text9">13sp</dimen>
<dimen name="text10">15sp</dimen>
<dimen name="text11">16sp</dimen>
<dimen name="text12">18sp</dimen>
<dimen name="text13">19sp</dimen>
<dimen name="text14">21sp</dimen>
<dimen name="text15">22sp</dimen>
<dimen name="text16">24sp</dimen>
<dimen name="text17">25sp</dimen>
<dimen name="text18">27sp</dimen>
<dimen name="text19">28sp</dimen>
<dimen name="text20">30sp</dimen>
<dimen name="text21">31sp</dimen>
<dimen name="text22">33sp</dimen>
<dimen name="text23">34sp</dimen>
<dimen name="text24">36sp</dimen>
<dimen name="text25">37sp</dimen>
<dimen name="text26">39sp</dimen>
<dimen name="text28">42sp</dimen>
<dimen name="text30">45sp</dimen>
<dimen name="text32">48sp</dimen>
<dimen name="text34">51sp</dimen>
<dimen name="text35">52sp</dimen>
<dimen name="text36">54sp</dimen>
<dimen name="text38">57sp</dimen>
<dimen name="text40">60sp</dimen>
<dimen name="text50">75sp</dimen>
<dimen name="text60">90sp</dimen>
<dimen name="text65">97sp</dimen>
<dimen name="text70">105sp</dimen>
<!-- height -->
<dimen name="height110">165dp</dimen>
<dimen name="height120">180dp</dimen>
<dimen name="height130">195dp</dimen>
<dimen name="height140">210dp</dimen>
<dimen name="height150">225dp</dimen>
<dimen name="height160">240dp</dimen>
<dimen name="height165">245dp</dimen>
<dimen name="height170">250dp</dimen>
<dimen name="height175">260dp</dimen>
<dimen name="height180">270dp</dimen>
<dimen name="height185">275dp</dimen>
<dimen name="height190">285dp</dimen>
<dimen name="height195">293dp</dimen>
<dimen name="height200">300dp</dimen>
<dimen name="height220">330dp</dimen>
<dimen name="height250">375dp</dimen>
<dimen name="height300">495dp</dimen>
<dimen name="height330">440dp</dimen>
<dimen name="height350">525dp</dimen>
<dimen name="height400">600dp</dimen>
<!-- Padding -->
<dimen name="padding1">2dp</dimen>
<dimen name="padding2">3dp</dimen>
<dimen name="padding3">5dp</dimen>
<dimen name="padding4">6dp</dimen>
<dimen name="padding5">7dp</dimen>
<dimen name="padding6">9dp</dimen>
<dimen name="padding7">10dp</dimen>
<dimen name="padding8">12dp</dimen>
<dimen name="padding9">13dp</dimen>
<dimen name="padding10">15dp</dimen>
</resources>
在values-sw-720dp
中dimens.xml文件
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Margins -->
<dimen name="margin1">2dp</dimen>
<dimen name="margin2">4dp</dimen>
<dimen name="margin3">4dp</dimen>
<dimen name="margin5">10dp</dimen>
<dimen name="margin7">14dp</dimen>
<dimen name="margin10">20dp</dimen>
<dimen name="margin11">22dp</dimen>
<dimen name="margin13">26dp</dimen>
<dimen name="margin15">30dp</dimen>
<dimen name="margin18">36dp</dimen>
<dimen name="margin20">40dp</dimen>
<dimen name="margin25">50dp</dimen>
<dimen name="margin27">54dp</dimen>
<dimen name="margin30">60dp</dimen>
<dimen name="margin35">70dp</dimen>
<dimen name="margin40">80dp</dimen>
<dimen name="margin45">90dp</dimen>
<dimen name="margin50">100dp</dimen>
<dimen name="margin55">110dp</dimen>
<dimen name="margin60">120dp</dimen>
<dimen name="margin65">130dp</dimen>
<dimen name="margin70">140dp</dimen>
<dimen name="margin75">150dp</dimen>
<dimen name="margin80">160dp</dimen>
<dimen name="margin85">170dp</dimen>
<dimen name="margin90">180dp</dimen>
<dimen name="margin95">190dp</dimen>
<dimen name="margin100">200dp</dimen>
<!-- Text Size -->
<dimen name="text8">16sp</dimen>
<dimen name="text10">20sp</dimen>
<dimen name="text11">22sp</dimen>
<dimen name="text12">24sp</dimen>
<dimen name="text13">26sp</dimen>
<dimen name="text14">28sp</dimen>
<dimen name="text15">30sp</dimen>
<dimen name="text16">32sp</dimen>
<dimen name="text17">34sp</dimen>
<dimen name="text18">36sp</dimen>
<dimen name="text19">38sp</dimen>
<dimen name="text20">40sp</dimen>
<dimen name="text21">42sp</dimen>
<dimen name="text22">44sp</dimen>
<dimen name="text23">46sp</dimen>
<dimen name="text24">48sp</dimen>
<dimen name="text25">50sp</dimen>
<dimen name="text26">52sp</dimen>
<dimen name="text28">56sp</dimen>
<dimen name="text30">60sp</dimen>
<dimen name="text32">62sp</dimen>
<dimen name="text34">68sp</dimen>
<dimen name="text35">70sp</dimen>
<dimen name="text36">72sp</dimen>
<dimen name="text38">76sp</dimen>
<dimen name="text40">80sp</dimen>
<dimen name="text50">100sp</dimen>
<dimen name="text60">120sp</dimen>
<dimen name="text65">130sp</dimen>
<dimen name="text70">140sp</dimen>
<!-- height -->
<dimen name="height110">220dp</dimen>
<dimen name="height120">240dp</dimen>
<dimen name="height130">260dp</dimen>
<dimen name="height140">280dp</dimen>
<dimen name="height150">300dp</dimen>
<dimen name="height160">320dp</dimen>
<dimen name="height165">330dp</dimen>
<dimen name="height170">340dp</dimen>
<dimen name="height175">350dp</dimen>
<dimen name="height180">360dp</dimen>
<dimen name="height185">370dp</dimen>
<dimen name="height190">380dp</dimen>
<dimen name="height195">390dp</dimen>
<dimen name="height200">400dp</dimen>
<dimen name="height220">440dp</dimen>
<dimen name="height250">500dp</dimen>
<dimen name="height300">600dp</dimen>
<dimen name="height330">660dp</dimen>
<dimen name="height350">700dp</dimen>
<dimen name="height400">800dp</dimen>
<!-- Padding -->
<dimen name="padding1">2dp</dimen>
<dimen name="padding2">4dp</dimen>
<dimen name="padding3">6dp</dimen>
<dimen name="padding4">8dp</dimen>
<dimen name="padding5">10dp</dimen>
<dimen name="padding6">12dp</dimen>
<dimen name="padding7">14dp</dimen>
<dimen name="padding8">16dp</dimen>
<dimen name="padding9">18dp</dimen>
<dimen name="padding10">20dp</dimen>
</resources>
执行此操作后,您可以更改您的布局xml文件,如下所示:
我刚刚更改了一个线性布局文件
您应该申请此xml文件中的所有其他布局
See this below sample:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:scrollbarStyle="insideOverlay"
>
<LinearLayout
android:id="@+id/layout_status"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/wight"
android:baselineAligned="false"
android:orientation="vertical" >
<TextView
android:id="@+id/tseriesname"
android:layout_width="fill_parent"
android:layout_height="@dimen/margin20"
android:layout_margin="@dimen/margin5"
android:gravity="center"
android:singleLine="true"
android:text="@string/series_name"
android:textColor="@color/textgraycolor"
android:textSize="@dimen/text10"
android:textStyle="bold" />
..........
..............
................
...................
像这样你的应用程序应该支持多个屏幕。
您可以使用不同的布局来支持设备。
并且应该有drawable-hdpi,drawable-mdpi,drawable-xdpi,drawable-xxdpi中的图像,以便完美地查看图像。
我认为这对你的回答很有帮助。 :)
答案 4 :(得分:1)
你可以做很多事情
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
您可以支持最小宽度布局目录,并在那里有5&#34;,7&#34;,10&#34;等等。
res/layout/main_activity.xml # For handsets (smaller than 480dp available width)
res/layout-sw480dp/main_activity.xml # For phones (480dp wide and bigger)
res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wide and bigger)
您还可以使用不同的值文件夹为每个屏幕分辨率组设置不同的dimens.xml Supporting Multiple Screens
答案 5 :(得分:1)
尝试使用谷歌的设计库。 Percentage Layout它将满足您的要求
答案 6 :(得分:0)
尝试将父布局作为线性布局,然后将android:weightsum
属性设置为父级。最后,使用权重android:weight
属性对齐子视图。通过这种方式,您可以在所有屏幕尺寸上拥有统一的UI。
答案 7 :(得分:0)
您应该使用layout_weight
并更改
android:layout_width="(fixedvalue)"
和android:layout_height="fixed_value"
到android:layout_width="match_parent
&#34;和android:layout_height="wrap_content"
。你可以做一些研究,你会发现这很容易理解。
答案 8 :(得分:-1)
您可以通过代码而不是layout.xml创建布局。