I am trying to make images in this layout (with id itemslayout) wrap the image rather than match the parent height. The imageviews dont seem to listen to my XML code! What is the solution. Here is the XML:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/pullupTitleBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/orange"
android:orientation="vertical" >
<xx.xxxxxx.xxxxx.android.ui.views.CustomTextView
android:id="@+id/someTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp"
android:text="@string/lolperks"
android:textColor="@color/white"
android:textSize="22sp" />
<Button
android:id="@+id/upanddownButton"
style="@style/OrangeSmallButton"
android:layout_width="37dp"
android:layout_height="34dp"
android:layout_gravity="right"
android:layout_marginRight="6dp"
android:layout_marginTop="6dp"
android:background="@drawable/double_arrows"
android:contentDescription="UpButton"
android:onClick="downButtonClicked"
android:scaleY="-1"
android:text=" " />
</FrameLayout>
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="pick a card any card "
android:textAppearance="?android:attr/textAppearanceSmall" />
<LinearLayout
android:id="@+id/itemslayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="0.333" >
<ImageView
android:id="@+id/ImageView02"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/card" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="0.333" >
<ImageView
android:id="@+id/ImageView01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/card" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.333"
android:layout_margin="10dp" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/card" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
here is a screenshot of what is happening. I need it to be wrapping the image not matching the parent.
What i want:
I know it might sound confusing, but try putting one more layout inside of the outermost layout and set the height to wrap_content. With layouts, it causes everything inside of it to wrap content rather than causing the actual layout to do it. You need this buffer layout though so that the outermost layout will still fill the whole screen.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/pullupTitleBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/orange"
android:orientation="vertical" >
<xx.xxxxxx.xxxxx.android.ui.views.CustomTextView
android:id="@+id/someTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp"
android:text="@string/lolperks"
android:textColor="@color/white"
android:textSize="22sp" />
<Button
android:id="@+id/upanddownButton"
style="@style/OrangeSmallButton"
android:layout_width="37dp"
android:layout_height="34dp"
android:layout_gravity="right"
android:layout_marginRight="6dp"
android:layout_marginTop="6dp"
android:background="@drawable/double_arrows"
android:contentDescription="UpButton"
android:onClick="downButtonClicked"
android:scaleY="-1"
android:text=" " />
</FrameLayout>
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="pick a card any card "
android:textAppearance="?android:attr/textAppearanceSmall" />
<LinearLayout
android:id="@+id/itemslayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="0.333" >
<ImageView
android:id="@+id/ImageView02"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/card" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="0.333" >
<ImageView
android:id="@+id/ImageView01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/card" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.333"
android:layout_margin="10dp" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/card" />
</FrameLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.