Reputation: 110
I got RelativeLayout
in content:
<RelativeLayout xmlns:
android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:maxWidth="350dp"
></RelativeLayout>
android:maxWidth="350dp"
doesn't work. With wrap_content
for layout_width
and layout_height
neither works `.
Upvotes: 4
Views: 4178
Reputation: 1152
The documentation for RelativeLayout and even ViewGroup doesn't mention an attribute for android:maxWidth. This attribute, as well maxHeight, are instead declared per View, inside of the attrs.xml file of the Android SDK. So, for example the Views TextView, EditText, ImageView and ContraintLayout, all have that attribute, but Spinner does not. You have to implement complex layouts, create custom ViewGroups that support maxWidth/maxHeight or use multiple layout files with dimension modifiers to achieve the same effect.
Upvotes: 4
Reputation: 110
I realized that maxWidth
param for RelativeLayout
couldn't and can't work. But it's not recognized as wrong parameter for RelativeLayout
by Android Studio UI. Maxwidth
param is available for Views
and ConstraintLayout
so in the solution I will add relative positioning
to ConstraintLayout
with this documentation .
Upvotes: 2