CSS中的“float:right”属性在LinearLayout中相当于android?

前端之家收集整理的这篇文章主要介绍了CSS中的“float:right”属性在LinearLayout中相当于android?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在CSS上我们可以写:
  1. <div style="float:right"> Text1 </div>
  2. <div style="float:right"> Text2 </div>

通过这种方式Text1将出现在右边..

我试图对LinearLayout做同样的事情,View应该从右到左显示

  1. <LinearLayout android:id="@+id/linearLayout1" android:layout_gravity="right" android:gravity="right"
  2. android:layout_width="fill_parent" android:layout_height="wrap_content"
  3. android:layout_weight="1" android:weightSum="2" android:orientation="horizontal">
  4. <!-- First Column should be on the right : Text1-->
  5. <LinearLayout android:id="@+id/linearLayout2"
  6. android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_gravity="right" android:gravity="right"
  7. android:layout_weight="1">...</LinearLayout>
  8. <!-- Second Column should be on the left : Text2 -->
  9. <LinearLayout android:id="@+id/linearLayout3"
  10. android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_gravity="right" android:gravity="right"
  11. android:layout_weight="1">...</LinearLayout>
  12. </LinearLayout>

谢谢

解决方法

这可能是
  1. <LinearLayout android:id="@+id/linearLayout1"
  2. android:gravity="right"
  3. android:layout_width="fill_parent"
  4. android:layout_height="wrap_content"
  5. android:layout_weight="1"
  6. android:weightSum="2"
  7. android:orientation="horizontal"
  8. android:layout_gravity="right"
  9. >
  10. <!-- Second Column should be on the left : Text2 -->
  11. <LinearLayout android:id="@+id/linearLayout3"
  12. android:layout_width="wrap_content" android:layout_height="fill_parent"
  13. android:layout_weight="1">...</LinearLayout>
  14. <!-- First Column should be on the right : Text1-->
  15. <LinearLayout android:id="@+id/linearLayout2"
  16. android:layout_width="wrap_content" android:layout_height="fill_parent"
  17. android:layout_weight="1">...</LinearLayout>

猜你在找的CSS相关文章