android-drawable

How to get the drawable from relative layout in android

眉间皱痕 提交于 2019-12-02 13:25:26
What i have done: I have set the bitmap for a relative layout as below RelativeLayout root; root= (RelativeLayout) itemView.findViewById(R.id.root); BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 4; Bitmap preview_bitmap = BitmapFactory.decodeResource(context.getResources(),godImages[position], options); Drawable drawable = new BitmapDrawable(context.getResources(),preview_bitmap); root.setBackgroundDrawable(drawable); What i am trying to do: I am trying to get the bitmap from the relativelayout back again that was set so that i can pass to another activity

Rotating FloatingActionButton

Deadly 提交于 2019-12-02 08:45:53
I believe most of you all have seen the rotating FloatingActionButton in apps such as Google keep, push bullet and even Google inbox app. I am trying to achieve this rotation by having an animation file that is : <?xml version="1.0" encoding="UTF-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="0" android:toDegrees="135" android:pivotX="50%" android:pivotY="50%" android:repeatCount="0" android:fillAfter="true" android:fillEnabled="true" android:duration="100" /> Right now I am using makovkastar library to do this FAB button. However, when I set the

Android Drawable Image not Showing

孤街醉人 提交于 2019-12-02 05:18:33
问题 I am trying to programically set the background of my app with an image in my drawable-hdpi folder. It is only seeing the default ic_launcher file in R.drawable so when I go to set the background, its simply unexistant. I am using this class as a fragment class with a swipe menu so maybe that has something to do with it. EDIT: I was able to set the background in my xml file, but I couldn't set the background in my oncreateview method. public class inputClass extends Fragment { @Override

Android Drawable Image not Showing

风流意气都作罢 提交于 2019-12-02 01:31:14
I am trying to programically set the background of my app with an image in my drawable-hdpi folder. It is only seeing the default ic_launcher file in R.drawable so when I go to set the background, its simply unexistant. I am using this class as a fragment class with a swipe menu so maybe that has something to do with it. EDIT: I was able to set the background in my xml file, but I couldn't set the background in my oncreateview method. public class inputClass extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View

Android - imageView.getDrawable() returns null

纵然是瞬间 提交于 2019-12-01 21:35:03
问题 I am stuck on this seemingly easy issue. What am I doing wrong ? ImageView mImageView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mImageView = (ImageView)findViewById(R.id.control); ClipDrawable drawable = (ClipDrawable)mImageView.getDrawable(); drawable.setLevel(10); } The app crashes at drawable.setLevel(10) with a NullPointerException (drawable is null). Here is my xml: circle.xml <?xml version=

Android - imageView.getDrawable() returns null

北慕城南 提交于 2019-12-01 19:37:31
I am stuck on this seemingly easy issue. What am I doing wrong ? ImageView mImageView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mImageView = (ImageView)findViewById(R.id.control); ClipDrawable drawable = (ClipDrawable)mImageView.getDrawable(); drawable.setLevel(10); } The app crashes at drawable.setLevel(10) with a NullPointerException (drawable is null). Here is my xml: circle.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android

Progress bar with image in center

我们两清 提交于 2019-12-01 18:50:05
Hi guys today i'am trying to do my custom progress bar, for that i created a spinner_inner and a spinner_outer, but my inner size is to large and overlaps the outer. my activity <ProgressBar style="@style/Spinner" android:layout_width="100dp" android:layout_height="100dp" android:indeterminateDrawable="@drawable/loading" /> <TextView android:id="@+id/login_status_message" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="16dp" android:fontFamily="sans-serif-light" android:text="@string/login_progress_signing_in" android:textAppearance="

Android - Drawable repeat shape to create pattern

风格不统一 提交于 2019-12-01 17:35:34
I need to create a pattern to set as a background of some View . I want the pattern to look something like this: I don't want to import any image to drawable, but instead, I want to create my own shapes, layer-list and the ultimate goal is to have a pattern as a background. Is is possible to achieve this without having to import any external image? 0X0nosugar You can get a pattern of repeating tiles based upon shape drawables by creating a custom View and overriding onDraw() . Let's start by creating the tile as a layer list made of shape drawables, in this case alternating squares of black

How to resize images at runtime for different screens?

笑着哭i 提交于 2019-12-01 12:58:45
I know that in Android Studio there are some plugins for including a drawable that help in creating a ldpi, mdpi, hdpi, etc image resource. But suppose I have an app in which some users upload images to a server and then I download the images and display them for other users, how can I adapt them so that they adapt to ldpi, mdpi, hdpi screens? Is there a library that runs on the server or client? Pavneet_Singh there are two ways , either you do it or let other do it you can use picasso (image loading library ) with fit function and just relax . link find the required size and compress the

How to resize images at runtime for different screens?

泪湿孤枕 提交于 2019-12-01 11:27:50
问题 I know that in Android Studio there are some plugins for including a drawable that help in creating a ldpi, mdpi, hdpi, etc image resource. But suppose I have an app in which some users upload images to a server and then I download the images and display them for other users, how can I adapt them so that they adapt to ldpi, mdpi, hdpi screens? Is there a library that runs on the server or client? 回答1: there are two ways , either you do it or let other do it you can use picasso (image loading