【发布时间】:2018-02-06 14:14:44
【问题描述】:
我有一个带有 xml 的 CustomViewGroup,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal">
<View
android:layout_width="?"
android:layout_height="?"
android:id="@+id/child"
/>
</merge>
我想像这样使用父级
<CustomViewGroup
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/parent"
app:itemWidth="30dp"
app:itemHeight="30dp"
/>
如您所见,我想从父属性读取我的孩子的宽度和高度。有可能吗?
类似的东西,从父主题中读取,对吗?当您从父主题设置项目背景之类的值时。
android:background="?attr/selectableItemBackground"
【问题讨论】:
标签: android android-layout android-custom-view android-theme android-styles