image - Android Crash when ImageButton Src Added -
i have 3 imagebuttons
in view. 1 of them has drawable in src
works. when add src
other 2 app crashes when tap same button had image @ first.
here code below:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="0px" android:paddingright="0px" android:paddingtop="0px" android:paddingbottom="0px" tools:context=".mainactivity"> <relativelayout android:layout_width="match_parent" android:layout_height="400px" android:id="@+id/relativelayout"> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge" android:text="large text" android:id="@+id/textview" /> </relativelayout> <view android:layout_width="match_parent" android:layout_height="500px" android:background="#2196f3" android:id="@+id/toprowbackground"/> <imagebutton android:layout_width="80px" android:layout_height="80px" android:layout_marginleft="20px" android:layout_margintop="20px" android:id="@+id/logout" android:background="@android:color/transparent" android:shadowcolor="@android:color/transparent" android:layout_weight="1" android:src="@drawable/log_out" android:scaletype="fitstart"/> <imageview android:layout_width="100px" android:layout_height="100px" android:layout_centerhorizontal="true" android:layout_margintop="100px" android:background="@android:color/transparent" android:shadowcolor="@android:color/transparent" android:layout_weight="1" android:src="@drawable/user_icon" android:scaletype="fitstart"/> <textview android:text="[username]" android:id="@+id/username" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:textcolor="#1b1b1b" android:textsize="60px" android:layout_margintop="240px"/> <textview android:text="points: [points]" android:id="@+id/points" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:textcolor="#1b1b1b" android:textsize="60px" android:layout_margintop="350px"/> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/toprowbackground" android:weightsum="3" android:orientation="vertical" android:background="#1b1b1b"> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:weightsum="2" android:paddingtop="5dp" android:paddingbottom="5dp" android:orientation="vertical" android:background="#ff1b1b1b" android:id="@+id/challengelayout"> <imagebutton android:layout_width="100dp" android:layout_height="0dp" android:layout_centervertical="true" android:id="@+id/challengeicon" android:background="@android:color/transparent" android:shadowcolor="@android:color/transparent" android:layout_weight="1" android:src="@drawable/challenge_icon" android:layout_gravity="center|bottom" android:padding="10dp" android:scaletype="fitcenter"/> <button android:id="@+id/challengebutton" android:layout_width="match_parent" android:text="challenge" android:background="#1b1b1b" android:shadowcolor="@android:color/transparent" android:textcolor="#2196f3" android:layout_height="0dp" android:layout_weight="1" android:textsize="18dp" android:scaletype="fitcenter" android:gravity="center_horizontal|top"/> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:weightsum="2" android:paddingtop="5dp" android:paddingbottom="5dp" android:orientation="vertical" android:background="#1b1b1b" android:id="@+id/leaderboardlayout"> <imageview android:id="@+id/leaderboardicon" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1" android:scaletype="fitcenter" android:layout_gravity="center|bottom" android:padding="10dp" android:background="@android:color/transparent" android:shadowcolor="@android:color/transparent" android:layout_margin="12px" android:src="@drawable/leaderboard_icon"/> <button android:id="@+id/leaderboardbutton" android:layout_width="match_parent" android:text="leaderboard" android:background="#1b1b1b" android:shadowcolor="@android:color/transparent" android:textcolor="#2196f3" android:layout_height="0dp" android:layout_weight="1" android:textsize="18dp" android:scaletype="fitcenter" android:gravity="center_horizontal|top"/> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:weightsum="2" android:paddingtop="5dp" android:paddingbottom="5dp" android:orientation="vertical" android:background="#1b1b1b" android:id="@+id/storelayout"> <imagebutton android:id="@+id/storeicon" android:layout_width="100dp" android:layout_height="0dp" android:layout_weight="1" android:scaletype="fitcenter" android:layout_gravity="center|bottom" android:padding="10dp" android:background="@android:color/transparent" android:shadowcolor="@android:color/transparent" android:src="@drawable/store_icon" /> <button android:id="@+id/storebutton" android:layout_width="match_parent" android:text="store" android:background="#1b1b1b" android:shadowcolor="@android:color/transparent" android:textcolor="#2196f3" android:layout_height="0dp" android:layout_weight="1" android:textsize="18dp" android:scaletype="fitcenter" android:gravity="center_horizontal|top"/> </linearlayout> </linearlayout> </relativelayout>
the issue seems have been image files large. once decreased size app started perform expected.
Comments
Post a Comment