android-drawable

Create a drawable with rounded top corners and a border on bottom

守給你的承諾、 提交于 2020-01-15 09:04:13
问题 This is what I came up with. <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item> <shape android:shape="rectangle" > <solid android:color="@color/grey" /> <padding android:bottom="1dp" /> <corners android:radius="0dp"/> </shape> </item> <item> <shape android:shape="rectangle" > <solid android:color="@color/white" /> <corners android:radius="1dp" android:bottomRightRadius="0dp" android:bottomLeftRadius="0dp" android

Dashes stroke-dasharray in Android Vector

落爺英雄遲暮 提交于 2020-01-14 14:55:13
问题 How to add dashed line on Android Vector Drawable? It seems "stroke-dasharray" from svg is not supported in Android Vector. Is any other way to do it? My drawable that I want to make dashed: <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="61dp" android:height="160dp" android:viewportWidth="61.0" android:viewportHeight="160.0"> <path android:pathData="M2,159C6,81.5 38,21 57,4" android:strokeColor="#FFCF4D" android:fillColor="#00000000" android.stroke-dasharray

Reference drawable from string-array in android [duplicate]

若如初见. 提交于 2020-01-12 02:19:29
问题 This question already has answers here : Storing R.drawable IDs in XML array (6 answers) Closed 5 years ago . how would I reference a drawable resource from the string xml file? I want to do <string-array name="my_array"> <item>@drawable/my_image</item> ... How would I do that? 回答1: for arrays of drawables ids, don't use string array just use <array> then to use them, get a TypedArray if the ids TypedArray images = getResources().obtainTypedArray(R.array.my_image_ids); int resourceId = images

Why Uri.parse() does not return valid image uri of an image in the drawable folder?

爱⌒轻易说出口 提交于 2020-01-07 02:56:09
问题 intent = new Intent(Intent.ACTION_SEND); intent.setType("image/jpg"); //intent.setType("image/*"); Uri imageUri = Uri.parse("android.resource://com.example.anjuthanm.intenttest/"+R.drawable.test_image); //Uri imageUri = Uri.parse("android.resource://com.example.anjuthanm.intenttest/drawable/test_image"); intent.putExtra(Intent.EXTRA_STREAM, imageUri); intent.putExtra(Intent.EXTRA_TEXT, "Sent from my app"); chooser = Intent.createChooser(intent, "Send Image"); startActivity(chooser); When I

Android place ImageView on top of Canvas

回眸只為那壹抹淺笑 提交于 2020-01-05 11:39:48
问题 how can I display a programmatically created ImageView on top of a previously created View Canvas? I tried using bringToFront(), but without success. Code: RelativeLayout root = findViewById(R.id.layout); ImageView img = new ImageView(GameGuessActivity.context); img.setImageResource(R.drawable.image); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(width, height); params.leftMargin = x; params.topMargin = y; root.addView(img, params); img.bringToFront(); The Image is

Android ShapeDrawable set Background and Border programmatically

一笑奈何 提交于 2020-01-03 16:57:05
问题 I have a ShapeDrawable : final ShapeDrawable drawable = new ShapeDrawable(shape); drawable.getPaint().setStyle(Paint.Style.FILL); drawable.getPaint().setColor(0xFFffffff); I want to set border(stroke) color and width for this drawable. I try setStyle(Paint.Style.FILL_AND_STROKE) but it set background and border with same color 回答1: Use drawable.getPaint().setStyle(Paint.Style.STROKE); drawable.getPaint().setStrokeWidth(2); // in pixel 来源: https://stackoverflow.com/questions/31103974/android

Drawer layout has overridden the background

梦想与她 提交于 2020-01-03 04:32:05
问题 I have a small but bothering problem. I have a drawable layout for my sliding menu, but when I put it in my XML, the background is totally untouchable because the drawer has filled and overridden on screen: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <com.astuetz.PagerSlidingTabStrip android

ViewGroupOverlay doesn't show view

ぃ、小莉子 提交于 2020-01-02 10:33:21
问题 I'm currently trying to create a puzzle game where I have a grid and each cell should be able to show a visual (and only visual) indication on touch. Therefore, I intent to use the ViewGroupOverlay (with getOverlay()) with a custom view: In each CellView @Override public boolean onTouchEvent(MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View myView = inflater

ViewGroupOverlay doesn't show view

时光毁灭记忆、已成空白 提交于 2020-01-02 10:33:12
问题 I'm currently trying to create a puzzle game where I have a grid and each cell should be able to show a visual (and only visual) indication on touch. Therefore, I intent to use the ViewGroupOverlay (with getOverlay()) with a custom view: In each CellView @Override public boolean onTouchEvent(MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_DOWN) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View myView = inflater

android button with half circle edges

微笑、不失礼 提交于 2020-01-02 03:06:48
问题 I am trying to create a shape to be used for my imagebuttons in my Android project that would essentially have half circles for the left and right sides. I thought I could just use a shape XML with a radius, but that just rounds the corners where I need the whole left and right sides to be half circles like the image below. My current XML for the shape looks like this: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape=