android - Why height of RelativeLayout change when I add a view to RelativeLayout. -
i'm drawing lines in relative layout.to this, add line views add relative layout. when add drawed lines relative layouts relative layout's height changes. why ? in advance ! :)
layout.xml
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" tools:context="com.mobisoft.kelimebul.local.oyun" android:backgroundtint="#ffffcd8d" android:backgroundtintmode="multiply" android:background="#ffff9f63" android:padding="7dp" android:id="@+id/s" android:orientation="vertical"> <relativelayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/relative" android:touchscreenblocksfocus="true" android:nestedscrollingenabled="true" android:layout_weight="1"> <gridview android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/gameboard" android:listselector="#00000000" android:background="@color/tahta_rengi" android:scrollbars="none" android:fastscrollalwaysvisible="false" android:fastscrollenabled="false" android:focusable="false" android:focusableintouchmode="false" android:drawselectorontop="true" /> </relativelayout> <horizontalscrollview android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/horizontalscrollview" android:background="@color/tahta_rengi" android:layout_weight="1"> <linearlayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/scrolinear"> </linearlayout> </horizontalscrollview> <relativelayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@color/backgroundcolor" android:backgroundtint="@color/backgroundcolortint" android:visibility="visible" android:layout_weight="1"> <linearlayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true" android:layout_marginright="5dp" android:layout_centerhorizontal="true"> <imageview android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/timeicon" android:src="@drawable/clock" android:scaletype="fitcenter" android:layout_gravity="center_horizontal" android:layout_marginright="4dp" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancemedium" android:id="@+id/time" android:gravity="center_vertical|center|right|center_horizontal" android:textsize="@dimen/score_textsize" android:layout_gravity="right" android:textalignment="center" android:layout_alignparentright="true" /> </linearlayout> <linearlayout android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancemedium" android:text="@string/remainingwordn" android:id="@+id/textview5" android:textsize="@dimen/score_textsize" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancemedium" android:id="@+id/remainingnumber" android:textsize="@dimen/score_textsize" /> </linearlayout> </relativelayout> </linearlayout>
activity.java // part code of activity
drawview drawview; drawview = new drawview(getapplicationcontext(), locs, view.getwidth(), colors.get(linecolor)); relativelayoutoflines.addview(drawview); // add view relativelayouts
drawview.java
public class drawview extends view { paint paint = new paint(); float locs[]; int strokewidth; int color; public drawview(context context, float locs[], int strokewidth, int color) { super(context); this.locs = locs; this.strokewidth = strokewidth; this.color = color; } @override public void ondraw(canvas canvas) { paint.setcolor(getcontext().getresources().getcolor(color)); paint.setalpha(100); paint.setstrokewidth(strokewidth); canvas.drawline(locs[0], locs[1], locs[2], locs[3], paint); // left, top, right, bottom canvas.save(); canvas.restore(); } }
before drawing: https://www.dropbox.com/s/oo79d8rvp4sa2nj/s.png?dl=0
after drawing : https://www.dropbox.com/s/vawjsxcbi6gd2go/s2.png?dl=0
Comments
Post a Comment