查了好多资料,发现还是不全,干脆自己整理吧,至少保证在我的做法正确的,以免误导读者,也是给自己做个记录吧!
原问题来自于优快云问答道频,更多解决方案见:http://ask.youkuaiyun.com/questions/2362
问题描述:
问题好像是没有把布局作为fill parent 对齐,上面是我用使的码代
为什么一个按钮在左边,其余的按钮都在右侧?
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/face">
<RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="100dp" android:gravity="center">
<ImageView android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:id="@+id/eyes" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/eyes1" />
<LinearLayout android:layout_marginTop="50dp" android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="horizontal">
<Button android:id="@+id/eyesback" android:layout_width="50dp" android:layout_height="50dp" />
<Button android:id="@+id/eyesforward" android:layout_height="50dp" android:layout_width="50dp" android:layout_gravity="right"></Button>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
每日一道理
喜欢海,不管湛蓝或是光灿,不管平静或是波涛汹涌,那起伏荡漾的,那丝丝的波动;喜欢听海的声音,不管是浪击礁石,或是浪涛翻滚,那轻柔的,那澎湃的;喜欢看海,不管心情是舒畅的或是沉闷的,不管天气是晴朗的或是阴沉的,那舒心的,那松弛的……
喜欢海,不管湛蓝或是光灿,不管平静或是波涛汹涌,那起伏荡漾的,那丝丝的波动;喜欢听海的声音,不管是浪击礁石,或是浪涛翻滚,那轻柔的,那澎湃的;喜欢看海,不管心情是舒畅的或是沉闷的,不管天气是晴朗的或是阴沉的,那舒心的,那松弛的……
解决方案:
用使上面的码代:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/face">
<RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="100dp" android:gravity="center">
<ImageView android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:id="@+id/eyes" android:background="@drawable/eyes1" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
<RelativeLayout android:layout_marginTop="50dp" android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="horizontal">
<Button android:id="@+id/eyesback" android:layout_width="50dp" android:layout_height="50dp" android:layout_alignParentLeft="true"/>
<Button android:id="@+id/eyesforward" android:layout_height="50dp" android:layout_width="50dp" android:layout_gravity="right" android:layout_alignParentRight="true"></Button>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
把 teh LinearLayout 改为变 Relative layout。
文章结束给大家分享下程序员的一些笑话语录: 系统程序员
1、头皮经常发麻,在看见一个蓝色屏幕的时候比较明显,在屏幕上什幺都看不见的时候尤其明显;
2、乘电梯的时候总担心死机,并且在墙上找reset键;
3、指甲特别长,因为按F7到F12比较省力;
4、只要手里有东西,就不停地按,以为是Alt-F、S;
5、机箱从来不上盖子,以便判断硬盘是否在转;
6、经常莫名其妙地跟踪别人,手里不停按F10;
7、所有的接口都插上了硬盘,因此觉得26个字母不够;
8、一有空就念叨“下辈子不做程序员了”;
9、总是觉得9号以后是a号;
10、不怕病毒,但是很害怕自己的程序;