layoutparams

EditText in dialog android

对着背影说爱祢 提交于 2019-12-05 13:01:14
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", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton)

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

爱⌒轻易说出口 提交于 2019-12-05 03:23:24
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" android:cacheColorHint="@android:color/transparent" android:divider="@null" android:listSelector="@null"/>

Using layoutparams in relativeLayout with dp

不羁的心 提交于 2019-12-04 16:44:35
I m making an app and i want to be able to move a view using its margins dynamically. I tried using this : RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)cover.getLayoutParams(); params.leftMargin= 470; params.topMargin= 20; cover.setLayoutParams(params); (cover is an ImageView) The problem with this code its that it uses px instead of dp. I also tried using DisplayMetrics to convert my px values to dp but failed . Can you help me ? You need to set margin according to dpi - DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager windowManager = (WindowManager)

Android navigation bar overlay

耗尽温柔 提交于 2019-12-04 08:59:49
For my application I have to draw a bitmap on top of the Navigation bar on the bottom of the android screen. I am curious to know if the WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY can be used to overlay the navigation bar? Use the WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS should work :) 来源: https://stackoverflow.com/questions/21382283/android-navigation-bar-overlay

Android: change LayoutParams of View added by WindowManager

倖福魔咒の 提交于 2019-12-04 00:59:49
I have overlay View managed by WindowManager , just like in this question . Briefly, it looks like this: WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE); my_view_layout_params = new WindowManager.LayoutParams( WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSLUCENT); wm.addView(my_view, my_view_layout_params); It works, but if i need to change layout params, i need to remove View and add it again, like that: wm.removeView(my_view); wm.addView(my_view, my_view_layout_params); It looks not very beautiful. I

Getting all MotionEvents with WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH

假装没事ソ 提交于 2019-12-03 16:35:06
My question refers directly to this question . The answer to that question shows how one can create a ViewGroup , embed it inside a WindowManager , and allow the WindowManager to catch MotionEvent s through onTouchEvent(MotionEvent event) . WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH is the flag that allows this this ViewGroup to receive MotionEvent s. However, according to documentation, this flag ...will not receive the full down/move/up gesture I want to know if there's a work-around or a way so that I can get all touch events including down, move, and up. A proof of concept is in

Programatically changing Textview height and width

浪子不回头ぞ 提交于 2019-12-02 20:15:53
问题 I have a textview that I want to change the width to match_parent and height to remain at wrap_content. It is nested within a horizontal linearlayout. It is the 2nd in 3 textviews each of which has a weight of 1. When this particular fragment is run it sets the other two buttons to previousButton.setVisibility(View.GONE); nextButton.setVisibility(View.GONE); TextView <TextView android:id="@+id/home" android:layout_width="0dp" android:layout_height="wrap_content" android:text="HOME" android

Programatically changing Textview height and width

这一生的挚爱 提交于 2019-12-02 08:07:31
I have a textview that I want to change the width to match_parent and height to remain at wrap_content. It is nested within a horizontal linearlayout. It is the 2nd in 3 textviews each of which has a weight of 1. When this particular fragment is run it sets the other two buttons to previousButton.setVisibility(View.GONE); nextButton.setVisibility(View.GONE); TextView <TextView android:id="@+id/home" android:layout_width="0dp" android:layout_height="wrap_content" android:text="HOME" android:layout_weight="1" android:background="@drawable/button_selector" android:layout_marginLeft="10dp" android

Setting Button's margin programmatically

て烟熏妆下的殇ゞ 提交于 2019-12-01 04:12:30
I am new to android and stuck in a very basic problem.I am working on an application in which I need to swipe images on fling.On every image I have to add buttons dynamically.I am adding buttons using AddContentView() to add buttons.Everything is working fine but I want to set the position of buttons dynamically.I have read at many places,everyone is using addView() to add buttons and setting their positions.I have tried this but it isn't working.Can anyone please tell me how to set the margins(position) of button using addContentView().Any help would highly be appreciated. Setting a buttons

Setting Button's margin programmatically

倾然丶 夕夏残阳落幕 提交于 2019-12-01 02:27:20
问题 I am new to android and stuck in a very basic problem.I am working on an application in which I need to swipe images on fling.On every image I have to add buttons dynamically.I am adding buttons using AddContentView() to add buttons.Everything is working fine but I want to set the position of buttons dynamically.I have read at many places,everyone is using addView() to add buttons and setting their positions.I have tried this but it isn't working.Can anyone please tell me how to set the