一居中问题
相对布局
TextView
1.当android:layout_width="match_parent"的时候
如果想居中用android:gravity="center_horizontal"
这个时候android:layout_gravity="center_horizontal"不其作用,设背景色看一下,就会知道,它已经和parent一样了,所以layout_gravity没有意义
2.当android:layout_width="wrap_content"的时候
如果想居中用android:layout_centerHorizontal="true"
相对布局
二. 线性布局,相对布局等margins不起作用
在root里面设置margins不起作用
例如:<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_margin="40dip"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="I'm a button" />
</LinearLayout
解决办法:在root中用padding 或者 在子view中用margin
三. 控件靠右的问题
当android:layout_width="wrap_content"的时候:android:layout_alignParentRight="true"
当android:layout_width="match_parent"的时候:android:gravity="right"
四:修改textSize sp为dp,这样的话,设置修改字体的大小,不放大
五. 设置颜色
在res/color的下面创建一个文件forget_password_text_color.xml
内容:<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:color="@color/forget_password_blue_light_pressed" />
<item android:state_focused="true" android:color="@color/forget_password_blue_light_pressed" />
<item android:state_pressed="true" android:color="@color/forget_password_blue_light_pressed" />
<item android:color="@color/forget_password_blue_light"></item>
</selector>
使用方式:
android:textColor="@color/forget_password_text_color"
相对布局
TextView
1.当android:layout_width="match_parent"的时候
如果想居中用android:gravity="center_horizontal"
这个时候android:layout_gravity="center_horizontal"不其作用,设背景色看一下,就会知道,它已经和parent一样了,所以layout_gravity没有意义
2.当android:layout_width="wrap_content"的时候
如果想居中用android:layout_centerHorizontal="true"
相对布局
二. 线性布局,相对布局等margins不起作用
在root里面设置margins不起作用
例如:<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_margin="40dip"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="I'm a button" />
</LinearLayout
解决办法:在root中用padding 或者 在子view中用margin
三. 控件靠右的问题
当android:layout_width="wrap_content"的时候:android:layout_alignParentRight="true"
当android:layout_width="match_parent"的时候:android:gravity="right"
四:修改textSize sp为dp,这样的话,设置修改字体的大小,不放大
五. 设置颜色
在res/color的下面创建一个文件forget_password_text_color.xml
内容:<?xml version="1.0" encoding="utf-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:color="@color/forget_password_blue_light_pressed" />
<item android:state_focused="true" android:color="@color/forget_password_blue_light_pressed" />
<item android:state_pressed="true" android:color="@color/forget_password_blue_light_pressed" />
<item android:color="@color/forget_password_blue_light"></item>
</selector>
使用方式:
android:textColor="@color/forget_password_text_color"