Windows平铺Android布局
我正在寻找android中的windows 8互动程序布局(布局与windows phone互动程序UI完全相同..)。尝试了很多表格/网格布局。不能让它完美。任何帮助都将不胜感激 它可能会帮助你Windows平铺Android布局,android,android-layout,android-intent,Android,Android Layout,Android Intent,我正在寻找android中的windows 8互动程序布局(布局与windows phone互动程序UI完全相同..)。尝试了很多表格/网格布局。不能让它完美。任何帮助都将不胜感激 它可能会帮助你 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.26"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_height="118dp"
android:layout_weight="1.00"
android:paddingLeft="50dp"/>
<Button
android:id="@+id/button2"
android:layout_width="156dp"
android:layout_height="122dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.84"
android:orientation="horizontal" >
<Button
android:id="@+id/button3"
android:layout_width="0dip"
android:layout_height="118dp"
android:layout_weight="1.00" />
<Button
android:id="@+id/button4"
android:layout_width="156dp"
android:layout_height="122dp" />
</LinearLayout>
</LinearLayout>
试着用这种方法,它可能会起作用
<com.felipecsl.asymmetricgridview.library.widget.AsymmetricGridView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView = (AsymmetricGridView) findViewById(R.id.listView);
// Choose your own preferred column width
listView.setRequestedColumnWidth(Utils.dpToPx(this, 120));
final List<AsymmetricItem> items = new ArrayList<>();
// initialize your items array
adapter = new ListAdapter(this, listView, items);
AsymmetricGridViewAdapter asymmetricAdapter =
new AsymmetricGridViewAdapter<>(this, listView, adapter);
listView.setAdapter(asymmetricAdapter);
}
@覆盖
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView=(AsymmetricGridView)findViewById(R.id.listView);
//选择您自己喜欢的列宽
setRequestedColumnWidth(Utils.dpToPx(this,120));
最终列表
android设备不运行windows,因此您不应使应用程序看起来像windows设备。是否将windows应用程序看起来像iOS应用程序?可能重复:尝试使用非对称gridview
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="3"
android:orientation="horizontal">
<android.support.v7.widget.AppCompatImageView
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_margin="5sp"
android:background="@color/backPink"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="5"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_margin="5sp"
android:layout_weight="3"
android:background="@color/dark_green" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_margin="5sp"
android:layout_weight="1"
android:background="@color/dark_blue" />
</LinearLayout>
<LinearLayout
android:layout_width="0dip"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_margin="5sp"
android:layout_weight="1"
android:background="@color/Teal" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_margin="5sp"
android:layout_weight="1"
android:background="@color/purple" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_margin="5sp"
android:layout_weight="1"
android:background="@color/orange"
android:orientation="horizontal">
<TextView
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|center"
android:text="Logout"
android:textSize="30sp" />
</LinearLayout>
</LinearLayout>