android-view

Android - Background color with different color and angles

百般思念 提交于 2019-12-23 10:39:04
问题 I'm trying to figure out how to create this background in xml, couldn't find anything that helped me. Ignore the circle image of the kid and the text of course, I am talking about the background itself, is there a way to create something like that in xml? Thanks in advance for any help. cheers! 回答1: I'm guessing you moved on, but you can do this using Vector Drawables. The following is not accurate (the line is not completely straight), but should give you a good start: New XML file: <?xml

Android - Background color with different color and angles

这一生的挚爱 提交于 2019-12-23 10:38:13
问题 I'm trying to figure out how to create this background in xml, couldn't find anything that helped me. Ignore the circle image of the kid and the text of course, I am talking about the background itself, is there a way to create something like that in xml? Thanks in advance for any help. cheers! 回答1: I'm guessing you moved on, but you can do this using Vector Drawables. The following is not accurate (the line is not completely straight), but should give you a good start: New XML file: <?xml

Android - Listener for catching changes in a View's properties (e.g. android:layout_marginTop)

こ雲淡風輕ζ 提交于 2019-12-23 09:26:07
问题 In Android, can you create a Listener for catching changes in a View's properties (width / height / margin / position relative to top of the screen)? I want to trigger an event when layout_marginTop="10dp" is changed to a different value. 回答1: What about implementing a OnLayoutChangeListener that gets called when a View is moved due to Layout Change new View().addOnLayoutChangeListener(new OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right,

Programmatically line up two views at a corner

纵饮孤独 提交于 2019-12-23 06:04:36
问题 So this seems like a very simple question, but I can't figure out how to get the proper location after scaling a view. I'm trying to line up an imageView to the bottom right corner of another imageView. This code works fine if I don't modify firstImageView . secondImageView.setX(firstImageView.getRight()); secondImageView.setY(firstImageView.getBottom()); But then after I apply a translation or scale to the firstImageView, the code above doesn't seem to work correctly (doesn't line up at

WindowManager.addView ontop(overlay) of soft key OR nav bar

家住魔仙堡 提交于 2019-12-23 05:29:24
问题 I saw an app that overlays whole screen including nav bar (or soft-key that has back, home, etc.) today. it's CF.Lumen(requires android 4.4+) by chainfire. I just remembered this is NOT POSSIBLE on general approach and many SO answers told me. So I looked down smali codes from Lumens apk(sorry chainfire), found 0x7d6 as type specifier, which is TYPE_SYSTEM_OVERLAY . In general, this makes a view overlays on top of lock screen. It looks good however it won't overlays nav bar area. even on lock

Getting previous RadioButton value from RadioGroup inside a RecyclerView

早过忘川 提交于 2019-12-23 04:32:30
问题 In the above value when I check the option "salt" it gives me the value of same position from the above item. So in this case it gives me "CH6" Like this when i check "Water" it gives me "CH4". So here is my RecyclerView , public class QuestionsAdapter extends RecyclerView.Adapter<QuestionsAdapter.ViewHolder> { List<String> names = new ArrayList<>(); Context c; String username; Map<String,Object> map = new HashMap<>(); ArrayList<QuestionData> questions = new ArrayList<>(); public

Center drawable and scale height

隐身守侯 提交于 2019-12-23 04:30:14
问题 Since I want to support tablets and smartphones without delivering a special "HD" version, I need to scale my Images depending on the resolution of the users device. This is the ImageView source that looks good on the Samsung Galaxy Nexus: <ImageView android:id="@+id/character" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:background="@android:color/transparent" android:scaleType=

Scrollable ListView with customized BaseAdapter is very slow

余生颓废 提交于 2019-12-23 02:55:34
问题 I have a customized BaseAdapter for my listView with this code: public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { } else { holder = (ViewHolder) convertView.getTag(); } convertView = mInflater.inflate(R.layout.user_submissions_customisation, null); holder = new ViewHolder(); holder.JournalName = (TextView) convertView.findViewById(R.id.JournalName); holder.SubmissionTitle = (TextView) convertView.findViewById(R.id

Fragment setRetainInstance(true) save View properties

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 15:09:53
问题 I'm confused about the best practice for saving the states of Views that live inside of fragments in Android. I thought that setRetainInstance(true) would do the trick; however, while this does retain the old global View references declared in the Fragment , those Views will not be used when inflating the layout. Thus, I have to manually transfer the properties from the old global View references to the new Views in the inflated layout. See the code below for how I'm doing this. public static

Why does bringToFront works only once

自闭症网瘾萝莉.ら 提交于 2019-12-22 10:44:29
问题 bringToFront works once and after that it no longer works. Why? when you click once it brings that view to front but when you try to bring back the view it no longer works . The touches/clicks work fine all the time. View view1,view2,view3,view4; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //sets the Bundle //code to initiate and putting the views in layout view1= findViewById(R.id.button1); view2=