layoutparams

Animation in changing LayoutParams in LinearLayout

为君一笑 提交于 2019-11-30 17:24:14
In my app there is a LinearLayout which has 0 Layout height. When I click the button this layout height should be LayoutParams.WRAP_CONTENT. This is the code I use in onclicklistner. LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); slider.setLayoutParams(lp); I want to animate this. How can I set animation to slider. If you want to implement the slider animation for your layout then see this demo . UPDATED Also see http://www.inter-fuser.com/2009/07/android-transistions-slide-in-and-slide.html Hope it will help you. If not then let me know. Thanks. Enjoy

How to set layout_span through code

☆樱花仙子☆ 提交于 2019-11-30 16:38:25
问题 Does anyone know how to set/change the android:layout_span="" of an EditText in Android at runtime. I already have the EditText defined in my XML file. <TableRow android:paddingTop="20dip" android:gravity="center_horizontal"> <EditText android:layout_width="150dip" android:text="" android:layout_height="40dip" android:id="@+id/p" android:layout_span="2"> </EditText> </TableRow> 回答1: You can use: TableRow.LayoutParams params = (TableRow.LayoutParams)editText.getLayoutParams(); params.span =

Animation in changing LayoutParams in LinearLayout

人走茶凉 提交于 2019-11-30 00:59:07
问题 In my app there is a LinearLayout which has 0 Layout height. When I click the button this layout height should be LayoutParams.WRAP_CONTENT. This is the code I use in onclicklistner. LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); slider.setLayoutParams(lp); I want to animate this. How can I set animation to slider. 回答1: If you want to implement the slider animation for your layout then see this demo. UPDATED Also see http://www.inter-fuser.com/2009/07

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

孤街醉人 提交于 2019-11-29 02:57:30
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 to work for the most part, but sometimes the view is not scaled. It seems to only consistenly work if

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

做~自己de王妃 提交于 2019-11-29 00:42:16
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.getSystemService(Context.WINDOW_SERVICE); WindowManager.LayoutParams p = (WindowManager.LayoutParams) parent

Setting Layout parameters in android

大兔子大兔子 提交于 2019-11-28 19:34:36
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, text and also gridview. Should the view parameters be defined based on the layout of the parent element

Add layout with parameters programmatically Android

随声附和 提交于 2019-11-28 09:10:53
Hello I have a main screen. <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" tools:context=".MainActivity" > <fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.SupportMapFragment"/> <ImageButton android:id="@+id/imageButton1" android:layout_width="55dp" android:layout_height="50dp" android:layout_alignParentTop="true" android:layout_marginTop="10dp" android

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

為{幸葍}努か 提交于 2019-11-28 09:05:50
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 ? Rect bounds = new Rect(); Paint textPaint = textView.getPaint(); textPaint.getTextBounds(text,0,text.length(),bounds); int height = bounds.height(); int width = bounds.width(); or textView.setText("bla"); textView.measure(0, 0); textView.getMeasuredWidth(); textView.getMeasuredHeight(

how to use correct dragging of a view on android

丶灬走出姿态 提交于 2019-11-28 08:49:41
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 image shrinks . another possible solution is to use the canvas in order to show the dragged content ,

android: LayoutParams for TextView makes the view disappear, programmatically

你。 提交于 2019-11-28 06:20:19
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 designed first, to use as reference for the code is this, and it works just fine: <TextView android:id