layoutparams

Layout params of loaded view are ignored

烂漫一生 提交于 2019-11-28 05:43:44
I'm trying to write my own custom View and I have problem with LayoutParams . The idea is to extend ViewGroup ( LinearLayout ) public class MyView extends LinearLayout{ public MyView(Context context, AttributeSet attrs) { super(context, attrs); } public MyView(Context context) { super(context); } public void putContent(){ setOrientation(HORIZONTAL); LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); for (int i = 0; i < 5; i++){ View view = inflater.inflate(R.layout.item, null); TextView tv = (TextView)view.findViewById(R.id.item_text); tv

Why do 9-patch graphics size correctly in the emulator but not on a phone?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 23:09:51
I have a RelativeLayout that has a 9-patch background image. The image is a simple speech bubble with a perfectly centered "arrow" at the bottom middle. The RelativeLayout is inflated and placed on a MapView. Using the emulator, the speech bubble can be easily pointed to a location and will expand to its contents (text, an image, or both). When I run my app on a phone however, the 9-patch doesn't stretch properly. The "arrow" for the speech bubble will be offset to the left by a very noticeable amount. I primarily test on a Nexus S, but also a Samsung Captivate and Nexus One. Targeting SDK 7.

android Exit from full screen mode

你说的曾经没有我的故事 提交于 2019-11-27 20:41:34
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 get normal screen from full screen. Thank you in advance. As per below code, i can hide the TitleBar

Android M ClassCastException: FrameLayout$LayoutParams cannot be cast to WindowManager$LayoutParams

假如想象 提交于 2019-11-27 15:24:12
问题 This piece of code works seems to work in android api 16 - 22 but does not work in api 23. I'm simply trying to display a popupwindow with options in it and dim the background below the popupwindow: WindowPopUp windowPopUp = new WindowPopUp(mContext, mPlaces.get(position), position, fromSearch); windowPopUp.showAtLocation(v, Gravity.CENTER, 0, 0); View parent = (View) windowPopUp.getContentView().getParent(); //dim the window in the background WindowManager wm = (WindowManager) mContext

How do I programmatically remove an existing rule that was defined in XML?

╄→尐↘猪︶ㄣ 提交于 2019-11-27 07:31:45
I have a linear layout that is contained inside a relative layout. It is set in the XML file to be to the right of another linear layout (this works fine). In some cases I want to change the relative position of the layout during the onCreate of the activity so I need to modify the "to the right of" param to relate to another layout. I tryed this: RelativeLayout.LayoutParams layoutParams; layoutParams = (RelativeLayout.LayoutParams) linearLayoutToMove .getLayoutParams(); layoutParams.addRule(RelativeLayout.RIGHT_OF, R.id.new_ref_LinearLayout); But it does not work :o( Any clues ? Michael You

How to find the Text Area(Height/Width) of TextView programmatically in android

我们两清 提交于 2019-11-27 02:37:49
问题 I have an EditText , a Button and a TextView . On clicking the button, textview shows the text written in edittext. Is it possible to find the size of textview occupied depending upon text. i.e. If It has three characters " abc ", what is width now, if it has 5 characters like " abcde " , then what is the width ? 回答1: Rect bounds = new Rect(); Paint textPaint = textView.getPaint(); textPaint.getTextBounds(text,0,text.length(),bounds); int height = bounds.height(); int width = bounds.width();

android: LayoutParams for TextView makes the view disappear, programmatically

假装没事ソ 提交于 2019-11-27 01:18:08
问题 I've hit this from various different angles. Basically the gist is this: I've layed out a template in XML for an interface which NEEDS to be run programmatically, so it's going to be populated dynamically during the run. The problem here, is that the XML TextView has quite a few layout tweaks (which work) and are necessary. But if I actually set them in code, the TextView doesn't even show up. (The TextView, by the way, is nested inside a TableRow, thus the call to weight.) The XML template I

Layout params of loaded view are ignored

ぐ巨炮叔叔 提交于 2019-11-27 01:01:40
问题 I'm trying to write my own custom View and I have problem with LayoutParams . The idea is to extend ViewGroup ( LinearLayout ) public class MyView extends LinearLayout{ public MyView(Context context, AttributeSet attrs) { super(context, attrs); } public MyView(Context context) { super(context); } public void putContent(){ setOrientation(HORIZONTAL); LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); for (int i = 0; i < 5; i++){ View view

Why do 9-patch graphics size correctly in the emulator but not on a phone?

一曲冷凌霜 提交于 2019-11-26 21:21:24
问题 I have a RelativeLayout that has a 9-patch background image. The image is a simple speech bubble with a perfectly centered "arrow" at the bottom middle. The RelativeLayout is inflated and placed on a MapView. Using the emulator, the speech bubble can be easily pointed to a location and will expand to its contents (text, an image, or both). When I run my app on a phone however, the 9-patch doesn't stretch properly. The "arrow" for the speech bubble will be offset to the left by a very

TYPE_SYSTEM_OVERLAY in ICS

时光总嘲笑我的痴心妄想 提交于 2019-11-26 20:17:48
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 Everything you describe is true. It is presumably to tighten up security, as the former behavior was the source of tapjacking attacks. I wrote a blog post recently about this change. Any idea's? Don