android-drawable

Material design suggestions for lists with avatar, text and icon

天大地大妈咪最大 提交于 2019-11-27 19:44:45
问题 I want to create Material Designed Android application and I try to follow all Google's suggestions about making nice layouts specially for the new RecylcerView . The RecyclerView has avatar ImageView , title and subtitle TextView and action icon ImageView . What values should I put in ImageView's properites for width and height so it supports different screen sizes and densities, and what size of those drawables should I choose from the system icons pack? material-design-icons-1.0.1

Android shape border with gradient

大城市里の小女人 提交于 2019-11-27 19:41:11
I want to create a border for a linearLayout. So I decide to create a shape. I want the border to have a gradient. The following is not doing it. It fills the rectangle and then creates a stroke. I don't want a filled rectangle, just the stroke. And I want to apply the gradient to the stroke. <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <gradient android:angle="360" android:centerColor="#e95a22" android:endColor="#ff00b5" android:gradientRadius="360" android:startColor="#006386" android:type="sweep" />

Scale image keeping its aspect ratio in background drawable

怎甘沉沦 提交于 2019-11-27 18:40:24
How do I make a background image fit the view but keep its aspect ratio when using <bitmap /> as a background drawable XML? None of <bitmap> 's android:gravity values gives the desired effect. It is impossible to achieve manipulating background attribute within xml-files only. There are two options: You cut/scale the bitmap programmatically with Bitmap.createScaledBitmap(Bitmap src, int dstWidth, int dstHeight, boolean filter) and set it as some View 's background. You use ImageView instead of background placing it as the first layout's element and specify android:scaleType attribute for it:

Change Icon Of Navigation Drawer

别等时光非礼了梦想. 提交于 2019-11-27 18:22:26
I am having trouble with changing my navigation drawer icon to a custom one. I've currently had to implement the standard drawer icon which has 3 horizontal lines on top, but now I want to replace this with my custom drawer icon. This is how my mDrawerToggle is at the moment: mDrawerToggle=new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.app_icon, R.string.drawer_open) { // My code }; Tarun Tak Here is the sample code taken from Creating a Navigation Drawer Activity.class public class MainActivity extends Activity { private DrawerLayout mDrawerLayout; private ActionBarDrawerToggle

Usage of mipmap launcher icons before Android 4.2?

瘦欲@ 提交于 2019-11-27 17:20:04
问题 I'm using Android Asset Studio to generate my launcher icon and I've seen that the output is now creating mipmap folders instead of drawable folders. Since mipmap support has been added since Android 4.2 and my application is targeting ICS 4.0.3 (API 15). Is it safe to use them ? and then don't have any ic_launcher icon in drawables folders ? update I confirm it's working fine. You can only use mipmap folders for Application icon 回答1: Mipmap folder support was added in Android SDK 11 or

Calling setCompoundDrawables() doesn't display the Compound Drawable

百般思念 提交于 2019-11-27 17:01:55
After I call the setCompoundDrawables method, the compound Drawable is not shown.. Drawable myDrawable = getResources().getDrawable(R.drawable.btn); btn.setCompoundDrawables(myDrawable, null, null, null); Any thoughts? I needed to be using setCompoundDrawablesWithIntrinsicBounds . aryan bahmani Use This (I tested). It works good Drawable image = context.getResources().getDrawable( R.drawable.ic_action ); int h = image.getIntrinsicHeight(); int w = image.getIntrinsicWidth(); image.setBounds( 0, 0, w, h ); button.setCompoundDrawables( image, null, null, null ); Image is blank because it hasn't

How to change color of CompoundDrawable on Button?

白昼怎懂夜的黑 提交于 2019-11-27 16:57:25
问题 I am trying to figure out how to change the color of icon which is in drawable left of button. Below is the XML code I am using : <Button android:layout_width="wrap_content" android:layout_height="20dp" android:layout_toRightOf="@+id/student_images" android:drawableLeft="@mipmap/ic_email_black_18dp" android:text=" myemail@gmail.com " android:layout_below="@+id/email" android:background="#00000000" android:layout_marginBottom="20dp" android:fontFamily="sans-serif" android:textColor="@color

Dotted line is actually not dotted when app is running on real Android device

試著忘記壹切 提交于 2019-11-27 15:35:20
问题 in my app I use XML defined vertical dotted line. <?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="90" android:toDegrees="90"> <shape android:shape="line"> <stroke android:width="1dp" android:color="@color/light_gray" android:dashWidth="2dp" android:dashGap="4dp" /> </shape> When I am nitpicking my layout in Android Studio, the line is rendered properly dotted, as it should, but problem comes out when I run the app

How rotate line in Android XML?

こ雲淡風輕ζ 提交于 2019-11-27 14:38:06
问题 I'm trying to draw a diagonal line in an Android app with the XML, but it is not working. It simply draws a horizontal line. main.xml : <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:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal

Changing color in a shape inside a layer-list programmatically

别说谁变了你拦得住时间么 提交于 2019-11-27 09:24:52
I am trying to change programmatically the color of the selectable_kachel_shape . Here is the xml file: kachel_ticked_style.xml <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:id="@+id/selectable_kachel_shape" android:shape="rectangle" > <stroke android:width="5dp" android:color="@color/headrbar_color" /> </shape> </item> <item> <rotate android:fromDegrees="45" android:pivotX="120%" android:pivotY="100%" android:toDegrees="45" > <shape android:shape="line" > <stroke android:width="40dp" android:color="@color/headrbar_color" /> </shape> </rotate> <