android-view

Android Wear CircledImageView (and DelayedConfirmationView) Always Square

我与影子孤独终老i 提交于 2019-12-10 21:51:46
问题 Anytime I try to use a CircledImageView (I'm developing on an LG G Watch) my image has a squared background. I get the same result with a DelayedConfirmationView , plus there is no "countdown animation." 回答1: Turns out the issue with the rounding was that I was specifying the layout_width and layout_height in dp instead of using wrap_content . The issue with the "countdown" animation is that there needs to be a border width and color specified. EDIT: Here's a sample of what I was using ( app

How to understand that android finished drawing a view? [duplicate]

こ雲淡風輕ζ 提交于 2019-12-10 20:40:30
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: When has the Activity finished drawing itself? I want to know when a view completes its drawing, is that possible? How can I understand if android finished drawing a view or not? 回答1: Add a ViewTreeObserver to it. Sample, TextView pagerView1=new TextView(this); ViewTreeObserver textViewTreeObserver=pagerView1.getViewTreeObserver(); textViewTreeObserver.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

How to position a view on top of another view in RelativeLayout?

戏子无情 提交于 2019-12-10 20:11:57
问题 I have a TextView (indicated in green below) and a LinearLayout (indicated in red below) in a RelativeLayout . I want to position the TextView on top of the LinearLayout , like this: However, I tried this: <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/linear_layout"> <!--some other views--> </LinearLayout> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout

How to implement two fragments in single view?

痴心易碎 提交于 2019-12-10 18:19:00
问题 I have an application which has 3 fragments. And it works fine viewpager. But I need to implement similar view like in Android Play store. Initially they have "Featured" Tab. When you swipe left we can see "Categories" tab. But half of the screen still filled with "Featured" tab contents. How can I implement that view? Any idea? 回答1: Here is the actual answer. Posting after a long time. Add this method in your adapter: @Override public float getPageWidth(int position) { if (position == 0) {

Are Android View transformations applied after rasterization?

只谈情不闲聊 提交于 2019-12-10 17:47:03
问题 The lines (A) and the lines (B) in the code below should produce the same image. Yet lines (A) produce instead the image: What is happening? Are View/Canvas transformations applied after rasterization? import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Rect; import android.graphics.RectF; import android.view.View; import android.graphics.Matrix; public class MyView extends View { Paint paint = new Paint(); public MyView

Android: custom view from inflated layout

主宰稳场 提交于 2019-12-10 15:53:14
问题 I am creating my own layout based on RelativeLayout as a class in code I have basics of the layout defined in XML R.layout.menu_layout (style, drawable for background, margin, height) If I would not need a class then I would call inflater to do this: RelativeLayout menuLayout = (RelativeLayout)inflater.inflate(R.layout.menu_layout, root); But I would like to be calling my own class instead MenuLayout menuLayout = new MenuLayout(myparams); Since I need to create a class I need to somehow

How to change android status bar color to white and status bar icon color to grey

拜拜、爱过 提交于 2019-12-10 14:11:55
问题 i am trying to change color of my status bar to white with grey icons. i have tried almost every code solution for this problem but non of them worked for me. i am using this java fucntion to change it and i am also posting my style(21) code. public static void statusBarColor(Window window, Context ctx) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { //Window window = getActivity().getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

How can I define the size of the drawables in the style file?

早过忘川 提交于 2019-12-10 13:42:59
问题 I would like to specify just once in res/values/styles.xml the size of two checkboxes and their four shape drawables res/drawable/cb1_checked.xml res/drawable/cb1_unchecked.xml res/drawable/cb2_checked.xml res/drawable/cb2_unchecked.xml . This way the size would appear one time in the style rather than four in the drawables. Neither of the two attempts below work. Can you suggest a solution? (If you see what's wrong with these two attempts, please do mention it.) -----------------------------

WebView and GridView into ScrollView, View too large to fit into drawing cache

余生颓废 提交于 2019-12-10 13:09:46
问题 I have a layout memory issue. When I have a large webview it doesn't shows anything and the logcat shows "View too large to fit into drawing cache". The layout is: <ScrollView android:id="@+id/scrollNoticia" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/ficha_curva" android:layout_below="@+id/linea" android:scrollbars="none" > <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingBottom=

how to copy a text to the Clipboard in android [duplicate]

空扰寡人 提交于 2019-12-10 11:38:38
问题 This question already has answers here : How to copy text programmatically in my Android app? (9 answers) Closed 6 years ago . I want to copy some text in temprory memory : TextView tv = (int)findViewById(R.id.txt); String str = tv.getText().toString(); now how an I copy str in clipboard ??? 回答1: Use ClipboardManager int sdk = android.os.Build.VERSION.SDK_INT; if(sdk < android.os.Build.VERSION_CODES.HONEYCOMB) { android.text.ClipboardManager clipboard = (android.text.ClipboardManager)