Android xml中的行间距
我想要这个: 我得到的是: 我的xml文件:Android xml中的行间距,android,xml,Android,Xml,我想要这个: 我得到的是: 我的xml文件: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:l
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="autogenie.plandetail.MainActivity">
<android.support.v7.widget.Toolbar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/view"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_below="@+id/view"
android:layout_alignParentStart="true"
android:id="@+id/relativeLayout">
<ImageView
android:layout_width="100dp"
android:layout_height="fill_parent"
android:id="@+id/imageView"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:src="@drawable/abc_list_selector_disabled_holo_dark" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Plan:"
android:id="@+id/textView"
android:layout_alignParentTop="true"
android:layout_toEndOf="@+id/imageView"
android:textColor="#000000"
android:textStyle="bold" />
<TextView
android:textColor="#000000"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Monthly Rental:"
android:id="@+id/textView2"
android:layout_below="@+id/textView"
android:layout_toEndOf="@+id/imageView" />
<TextView
android:textColor="#000000"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Free Data:"
android:id="@+id/textView3"
android:layout_below="@+id/textView2"
android:layout_toEndOf="@+id/imageView" />
<TextView
android:textColor="#000000"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Overage Charge:"
android:id="@+id/textView4"
android:layout_below="@+id/textView3"
android:layout_toEndOf="@+id/imageView" />
<TextView
android:textColor="#000000"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Network:"
android:id="@+id/textView5"
android:layout_below="@+id/textView4"
android:layout_toEndOf="@+id/imageView" />
<TextView
android:textColor="#000000"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Remarks:"
android:id="@+id/textView6"
android:layout_below="@+id/textView5"
android:layout_toEndOf="@+id/imageView" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/relativeLayout"
android:layout_centerHorizontal="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Features"
android:id="@+id/textView7"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:textStyle="bold" />
<TextView
android:textColor="#000000"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/textView8"
android:layout_alignParentStart="true"
android:layout_below="@+id/textView7"
android:text="@string/features" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Continue"
android:id="@+id/button"
android:layout_below="@+id/textView8"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:textColor="#ffffff"
android:background="#2c75ba"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</RelativeLayout>
我做错了什么
我的设计看起来不错:
我在一个文本视图中编写了整个文本,并引用了字符串资源:
<resources>
<string name="app_name">Plandetail</string>
<string name="features"> 
3GPLUS network 

5 WiFi-enabled Devices-Smartphone,Laptop,Tablets

 
Works with Laptop USB,Car Charger and Travel Charger 

Plug and Play 
 

EVDO Rev.B 800/1900 MHz-14.7Mbps/5.4Mbps 
 
WiFi 802.11b/g/n 
 
Dual LED indicators for Wi-Fi and Network 
 
Works with Laptop USB,Car Charger and Travel Charger
 
</string>
</resources>
请在文本视图中使用
android:lineSpacingExtra="2dp"
我希望它能解决您的问题。您可以在XML文件的文本视图中使用lineSpacingExtra和lineSpacingMultiplier。让我们知道这是否有效。您可以使用 android:lineSpacingExtra-文本行之间的额外间距。 android:lineSpacingMultiplier-文本行之间的额外间距,作为乘数
来源:我在你的代码中看到的一个大问题是,你需要缩小按钮,如果你把它缩小,你会看到文本开始排列得更好 您可以通过以下方式声明按钮的文本大小: android:textSize=35sp android:layout_marginTop=30dp 然后尝试第二行来帮助缩小按钮 亲爱的,试试看,效果很好 在字符串xml中生成字符串,如下所示 并在文本视图文本中使用它 用这个替换你的字符串
亲爱的,您可以在字符串xml中定义字符串,您可以在其中添加\n以生成新行,这样您就可以得到换行符我已经发布了答案,请尝试这样做。如果您想使用项目符号生成字符串,那么您必须使用TagHandler类它处理html标记我已替换您的字符串并发布检查它
<string name="text">3G Plus network \n\n 5wifi </string>
<string name="text">\n3GPLUS network\n\n5 WiFi-enabled Devices-Smartphone,Laptop,Tablets\n\nWorks with Laptop USB,Car Charger and Travel Charger\n\nPlug and Play\n\n
EVDO Rev.B 800/1900 MHz-14.7Mbps/5.4Mbps\n\nWiFi 802.11b/g/n\n\nDual LED indicators for Wi-Fi and Network\n\nWorks with Laptop USB,Car Charger and Travel Charger</string>