android学习1——制作title,2条横线夹住标题,切换语言改变使得title自适应d
2018-03-13 23:53
369 查看
使用场景:
当我们使用Android开发界面时,通常我们要对界面设置一个标题。但是,随着产品中语言的切换会导致字符串的长度发生改变,从而使得界面发生混乱。
下面的title的设置写在布局文件中,可以随着语言的切换,使得字符串长度发生变化,而不会使得界面发生混乱。
备注:当*.xml的主布局为<LinearLayout>时,需要将<LinearLayout 中的android:layout_centerHorizontal="true" 修改为android:layout_gravity="center_horizontal"
<RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="145dip"
>
<RelativeLayout
android:layout_width="870dip"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
>
<TextView
android:id="@+id/textview_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="@string/hello_world"
android:textSize="28sp"
/>
<View
android:background="#686868"
android:layout_width="wrap_content"
android:layout_height="0.5dip"
android:layout_centerHorizontal="true"
android:layout_toLeftOf="@id/textview_title"
android:layout_marginRight="10dip"
/>
<View
android:background="#686868"
android:layout_width="wrap_content"
android:layout_height="0.5dip"
android:layout_centerHorizontal="true"
android:layout_toRightOf="@id/textview_title"
android:layout_marginLeft="10dip"
/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
当我们使用Android开发界面时,通常我们要对界面设置一个标题。但是,随着产品中语言的切换会导致字符串的长度发生改变,从而使得界面发生混乱。
下面的title的设置写在布局文件中,可以随着语言的切换,使得字符串长度发生变化,而不会使得界面发生混乱。
备注:当*.xml的主布局为<LinearLayout>时,需要将<LinearLayout 中的android:layout_centerHorizontal="true" 修改为android:layout_gravity="center_horizontal"
<RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="145dip"
>
<RelativeLayout
android:layout_width="870dip"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
>
<TextView
android:id="@+id/textview_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="@string/hello_world"
android:textSize="28sp"
/>
<View
android:background="#686868"
android:layout_width="wrap_content"
android:layout_height="0.5dip"
android:layout_centerHorizontal="true"
android:layout_toLeftOf="@id/textview_title"
android:layout_marginRight="10dip"
/>
<View
android:background="#686868"
android:layout_width="wrap_content"
android:layout_height="0.5dip"
android:layout_centerHorizontal="true"
android:layout_toRightOf="@id/textview_title"
android:layout_marginLeft="10dip"
/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
相关文章推荐
- Android学习----自适应国际化语言
- Android学习----自适应国际化语言,android----
- Android学习–Android app 语言切换功能
- 【安卓学习之常见问题】 多国语言横竖屏时,自动切换到默认语言(android:configChanges的使用)
- 【Android】SlidingTabLayout实现标题栏,教你制作title标题 简单易学。
- Android学习–Android app 语言切换功能
- Android学习–Android app 语言切换功能
- Android Tablayout + viewpager 切换时修改tablayout title(标题)的字体颜色和字体大小
- android系统资源更换-语言切换或配置改变
- android 7.0 切换语言界面切换语言后点击“添加语言”的加号进入语言选择列表不做任何操作返回返现actionbar标题异常
- [置顶] 【Android】SlidingTabLayout实现标题栏,教你制作title标题 简单易学。
- Android学习–Android app 语言切换功能
- Android学习----自适应国际化语言
- Android学习–Android app 语言切换功能
- Swift - 获取、改变按钮的标题文本(UIButton点击切换title)
- Swift - 获取、改变按钮的标题文本(UIButton点击切换title)
- Android学习----自适应国际化语言
- Android学习–Android app 语言切换功能
- [Android]应用语言切换的三种方法
- UDK学习笔记之(一)——添加快捷键切换视角、加减角色移动速度,初始化改变视角