layoutparams

EditText in dialog android

 ̄綄美尐妖づ 提交于 2019-12-22 07:52:19
问题 i have made a edittext in a dialog but i cant get to change the height. AlertDialog.Builder editalert = new AlertDialog.Builder(this); editalert.setTitle("messagetitle"); editalert.setMessage("here is the message"); final EditText input = new EditText(this); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT); input.setLayoutParams(lp); editalert.setView(input); editalert.setPositiveButton("Send via email"

java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.RelativeLayout$LayoutParams

冷暖自知 提交于 2019-12-22 04:26:12
问题 I've just edited my XML, I've put slide menu code in my XML, but there is an error. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ffffff" > <ListView android:id="@+id/menu_content_menulist" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="8dp"

After changing a property on a LayoutParams object, do I need to call setLayoutParams again?

好久不见. 提交于 2019-12-18 03:03:21
问题 I have a View (containing an ad) that I need to scale to fit the screen width at a certain point in time (after the ad is loaded). So I have a method setHeight(myView) that calculates the correct height for the given screen width and changes the LayoutParams of the View accordingly. The crucial part of the code is this: LayoutParams params = myView.getLayoutParams(); int width = myView.getWidth(); if (params != null && width > 0) { params.height = (int) Math.round(ratio * width); } This seems

Setting Layout parameters in android

家住魔仙堡 提交于 2019-12-17 22:42:07
问题 Working with the XML file was easy as I could specify the parameters as <android:layout_width="fill_parent" android:layout_height="wrap_content"> But I am confused while specifying it through code. For each view I specify the parameters using view.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT)); I see that I have an option of specifying it as relative layout, frame layout etc. As of now I am using linear layout for all views such as images,

how to use correct dragging of a view on android

时间秒杀一切 提交于 2019-12-17 18:44:24
问题 it seems that there are a lot of solutions of how to use dragging of views on android . however, they are either too slow or buggy. a known solution is to have a framelayout , and the view simply changes its layoutParams as it moves using the OnTouchListener ,as described here: http://www.anddev.org/novice-tutorials-f8/android-drag-and-drop-of-normal-views-not-bitmaps-t13404.html however, if the view is an imageView , when reaching the most right (or most bottom) side of the framelayout , the

android Exit from full screen mode

六月ゝ 毕业季﹏ 提交于 2019-12-17 10:56:14
问题 I am working in Android. I need to show my activity in Full screen mode, and i did this using following code. getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); Now its looking like this:- Now I want to exit from this full mode so my activity should show as before. like this:- I have a button which is used to switch between full mode or normal mode, i will switch mode again and again. Please suggest me how can i do this. Means how can

TYPE_SYSTEM_OVERLAY in ICS

霸气de小男生 提交于 2019-12-17 04:59:26
问题 In Honeycomb I was able to create a system overlay with TYPE_SYSTEM_OVERLAY and receive touches with FLAG_WATCH_OUTSIDE_TOUCH. Now ICS has changed something. I can still create the system overlay, but i can't get touches. Now, i am able to create the same with TYPE_SYSTEM_ALERT and get touches, but it just catches the touchevents, and not passing them on like in Honeycomb. Any idea's? Kind regards 回答1: Everything you describe is true. It is presumably to tighten up security, as the former

Auto-fit TextView for Android

北战南征 提交于 2019-12-16 20:40:29
问题 Background Many times we need to auto-fit the font of the TextView to the boundaries given to it. The problem Sadly, even though there are many threads and posts (and suggested solutions) talking about this problem (example here, here and here), none of them actually work well. That's why, I've decided to test each of them till I find the real deal. I think that the requirements from such a textView should be: Should allow using any font, typeface, style, and set of characters. Should handle

Auto-fit TextView for Android

回眸只為那壹抹淺笑 提交于 2019-12-16 20:39:26
问题 Background Many times we need to auto-fit the font of the TextView to the boundaries given to it. The problem Sadly, even though there are many threads and posts (and suggested solutions) talking about this problem (example here, here and here), none of them actually work well. That's why, I've decided to test each of them till I find the real deal. I think that the requirements from such a textView should be: Should allow using any font, typeface, style, and set of characters. Should handle

View disappears after setting height of gridLayout to wrap_content

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 17:08:41
问题 I have a list view. The layout for each row is: <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.GridLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" app:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingRight="16dp" android:paddingLeft="16dp" app:columnCount="4"> <View android:layout_width="3dp" android:layout_height="wrap_content" app:layout_row=