0

I try to draw a canvas on the left of 2 textviews, this is an adapter in a list. However, now each element in the list has the height of the entire display... but it should be as small as possible (wrap_content). How to proceed?

I really want a FrameLayout, because I want to paint on top of the text. Maybe the ImageView and TextViews should be in a single FrameLayout with gravity?

Here is the code:

<FrameLayout
    android:layout_height="wrap_content"
    android:layout_width="fill_parent">
    <ImageView
        android:id="@+id/tree_item"
        android:layout_width="15dp"
        android:layout_height="wrap_content"
        android:scaleType="matrix"
        android:layout_alignTop="@+id/item_name_quantity"
        android:layout_alignBottom="@+id/item_price"/>
    <LinearLayout
        android:layout_width="fill_parent"
        android:id="@+id/text_heights"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <TextView
            android:id="@+id/item_name_quantity"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="left"
            android:paddingRight="1dp"
            android:paddingLeft="2dp"
            android:textSize="18sp"
            android:textColor="@color/COLOUR_ITEM_TEXT"
            android:text="2x special menu"/>
        <TextView
            android:id="@+id/item_price"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:paddingRight="2dp"
            android:gravity="right"
            android:text="15,75"
            android:textColor="@color/COLOUR_ITEM_TEXT"
            android:textSize="12sp"/>
    </LinearLayout>
</FrameLayout>
Bart Mensfort
  • 995
  • 11
  • 21
  • Hi Mike, at following link you see the picture I want to see on my screen. It's working in Linux, on the printer... and now I also want this in Android: [link](http://www.kassaku.nl/images/sampledata/printer/tree3.jpg) To paint the lines, I want to use an Imageview with a canvas and bitmap. – Bart Mensfort Nov 16 '15 at 21:44
  • I just realized I misread your question.My bad. I thought you meant "on top" as in vertically on top. Are you setting an image on the ImageView? – Mike M. Nov 16 '15 at 21:53
  • HI Mike, Drawing is not the problem. When you look at [link](https://play.google.com/store/apps/details?id=hha.zhongcan.microfood&hl=nl) it is the previous version for this app. On the left is the order, with grey/white background colour... there are about 10 menu items on the screen... but with the new layout I only get 1 menu item on screen.. why does it resize to maximum size, although I have wrap_content? – Bart Mensfort Nov 16 '15 at 21:54
  • Yeah, I was asking if you set an image, because that could cause the layout to expand vertically. But if you're just drawing on it, it wouldn't cause that. Can you post a screenshot of the current app with the bad layout? – Mike M. Nov 16 '15 at 22:07
  • @BartMensfort Some people think im reinventing the wheel and most refuse it, but theres plenty of questions about xml layout problems and i always comment; If you've read this you would not have asked this. http://stackoverflow.com/questions/29956014/why-should-we-use-xml-layouts – Nanoc Nov 17 '15 at 20:49

0 Answers0