feat: 调整页面布局

This commit is contained in:
niushuai233 2022-10-17 14:14:58 +08:00
parent 8f4e9d8078
commit b003dd17bb
5 changed files with 62 additions and 21 deletions

View File

@ -60,13 +60,16 @@ public class NavDeviceFragment extends Fragment {
for (int i = 0; i < 3; i++) {
HashMap<String, Object> m1 = new HashMap<>();
m1.put("device_item_imageView", R.drawable.ic_mark_as_read);
m1.put("device_item_textView", "卧室灯" + i);
m1.put("device_item_cardView_image", R.drawable.ic_device_light_1);
m1.put("device_item_cardView_text", "卧室灯" + i);
dataItem.add(m1);
}
// SimpleAdapter gvAdapter = new SimpleAdapter(getContext(), dataItem, R.layout.device_item,
// new String[]{"device_item_cardView_text"}, new int[]{R.id.device_item_cardView_text});
SimpleAdapter gvAdapter = new SimpleAdapter(getContext(), dataItem, R.layout.device_item,
new String[]{"device_item_imageView", "device_item_textView"}, new int[]{R.id.device_item_imageView, R.id.device_item_textView});
new String[]{"device_item_cardView_image", "device_item_cardView_text"}, new int[]{R.id.device_item_cardView_image, R.id.device_item_cardView_text});
deviceGv.setAdapter(gvAdapter);
}

View File

@ -1,25 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@id/device_item"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_height="100dp"
>
<androidx.cardview.widget.CardView
android:id="@id/device_item_cardView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardCornerRadius="12dp"
android:layout_centerInParent="true">
<ImageView
android:id="@+id/device_item_imageView"
android:layout_width="56dp"
android:layout_height="56dp"
app:srcCompat="@drawable/ic_home"
android:layout_centerHorizontal="true"
/>
<TextView
android:id="@+id/device_item_textView"
<RelativeLayout
android:id="@id/device_item_cardView_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/device_item_imageView"
android:layout_marginLeft="10dp"
>
<ImageView
android:id="@id/device_item_cardView_image"
android:layout_width="55dp"
android:layout_height="55dp"
app:srcCompat="@drawable/ic_home" />
<TextView
android:id="@id/device_item_cardView_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/device_item_cardView_image"
android:layout_marginTop="10dp"
android:textSize="12dp"
android:layout_centerHorizontal="true"
android:text="TextView"
/>
android:layout_centerVertical="true"
android:shadowColor="#000000"
android:shadowDx="0.3"
android:shadowDy="0.3"
android:shadowRadius="0.3"
android:text="TextView" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
</RelativeLayout>

View File

@ -19,10 +19,14 @@
</androidx.gridlayout.widget.GridLayout>
<GridView
android:id="@+id/device_gv"
android:id="@id/device_gv"
android:paddingTop="25dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:numColumns="2"
android:verticalSpacing="12dp"
android:horizontalSpacing="12dp"
android:background="@color/main_bg_color"
/>
</RelativeLayout>

View File

@ -7,4 +7,6 @@
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="gray">#FFAFAFAF</color>
<color name="main_bg_color">#F6F6F6</color>
</resources>

View File

@ -6,4 +6,13 @@
<item name="bottom_nav_set" type="id"/>
<!-- 首页 底部导航栏 end-->
<!--设备页 start-->
<item name="device_gv" type="id"/>
<item name="device_item" type="id"/>
<item name="device_item_cardView" type="id"/>
<item name="device_item_cardView_content" type="id"/>
<item name="device_item_cardView_image" type="id"/>
<item name="device_item_cardView_text" type="id"/>
<!--设备页 end-->
</resources>