android-view

Custom XML attributes without custom View in Fragment

我怕爱的太早我们不能终老 提交于 2020-01-01 05:18:13
问题 I'm trying to add custom XML attributes in existing View Adding them to a custom View is not a big deal but I don't know how to access those attributes in a "basic" View (e.g. TextView, LinearLayout, ImageView ...) And this is more difficult when there are Fragment and / or Library project involved So far here is my code Customs attributes definitions and XML (attrs.xml and the layout): <?xml version="1.0" encoding="utf-8"?> <resources> <declare-styleable name="StarWars"> <attr name="jedi"

Example usage for ContentLoadingProgressBar

梦想的初衷 提交于 2020-01-01 01:44:13
问题 I just jumped and found this class ContentLoadingProgressBar from the developer site in android. I searched couldn't find any usage or explanation for the class. I've listed down few questions on the class and would be great if someone answers it. How is it different from ProgressBar ? Should we show/hide the ProgressBar ourself ? Styling the ProgressBar ? https://developer.android.com/reference/android/support/v4/widget/ContentLoadingProgressBar.html 回答1: I had tried this : <android.support

In gridview adapter, getView(position == 0) was invoked too many times to measure layout when setImageBitmap() in a loader

微笑、不失礼 提交于 2019-12-31 17:55:59
问题 I have a GridView for showing some icons. BEFORE I had read this Displaying Bitmaps Efficiently from Android developer site, I was decoding bitmap from local path directly in getView() of adapter, like this : public View getView(int position, View convertView, ViewGroup parent) { ... ImageView icon = ...... (from getTag() of convertView) icon.setImageBitmap(BitmapUtil.decode(iconPath)); ... } this way works fine anyway, I called it [Direct Mode], the output log for getView() method should be

How to change the current tab highlighter color in Android ViewPager?

倖福魔咒の 提交于 2019-12-31 12:57:10
问题 Here is my layout inside ViewPager . I would like to change the color of the current tab highlighter which is below the text. Actually it is showing in black color. But I don't know whether it is a color by default or not. And also I have one more doubt. If I use PagerTitleStrip this tab highlighter doesn't appear. Is there a way to bring that with titlestrip? Here is my layout: <android.support.v4.view.PagerTabStrip android:id="@+id/pager_title_strip" android:layout_width="match_parent"

how to set width which is equal to another widget on android

老子叫甜甜 提交于 2019-12-31 12:36:33
问题 I need to draw a horizontal line below a text field such that the width of the line equals the text width (not the width of the full screen). In my app I have a textview below a view(Horizontal line). The width of the line view should be equal to the width of the textview . I tried android:layout_width="wrap_content" and "match_parent", which does not solve the problem. This is xml coding sample: ...... <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout

How to disable BottomSheetDialogFragment dragging

耗尽温柔 提交于 2019-12-31 10:41:57
问题 How to disable BottomSheetDialogFragment dragging by finger? I saw similar questions, but they're all about BottomSheet not BottomSheetDialogFragment . 回答1: Having created MyActivity as follows: public class MyActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my); new MyBottomSheetFragment().show(getSupportFragmentManager(), "tag"); } public static class

How to disable BottomSheetDialogFragment dragging

会有一股神秘感。 提交于 2019-12-31 10:41:08
问题 How to disable BottomSheetDialogFragment dragging by finger? I saw similar questions, but they're all about BottomSheet not BottomSheetDialogFragment . 回答1: Having created MyActivity as follows: public class MyActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my); new MyBottomSheetFragment().show(getSupportFragmentManager(), "tag"); } public static class

How to get exact position in pixels of my TextView?

*爱你&永不变心* 提交于 2019-12-31 04:54:05
问题 I have a smartphone of 2560 x 1440 px. Now I am using this function for my TextView : int[] locationOnScreen = new int[2]; txtAp.GetLocationInWindow(locationOnScreen); It is supposed to give me the total x and y coordinates in pixels. My TextView is pretty much in the middle of the screen, so supposedly at (1280,770). But the function returns [69, 1111]. How can that be? If that is not the way of doing that, then what is? 回答1: I have a smartphone of 2560 x 1440 px... My TextView is pretty

Getting window display from service android

僤鯓⒐⒋嵵緔 提交于 2019-12-30 06:33:53
问题 I am trying to display a window from service but don't getting it how to do this Here is my code-- In onStart method of Service LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.main1, null); WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE); WindowManager.LayoutParams params = new WindowManager.LayoutParams(); params.type = 2002; params.format = 1; params.flags = 40; params.height = WindowManager

Getting window display from service android

谁说胖子不能爱 提交于 2019-12-30 06:33:27
问题 I am trying to display a window from service but don't getting it how to do this Here is my code-- In onStart method of Service LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.main1, null); WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE); WindowManager.LayoutParams params = new WindowManager.LayoutParams(); params.type = 2002; params.format = 1; params.flags = 40; params.height = WindowManager