android-linearlayout

What's the quickest way to add several views to a LinearLayout?

半腔热情 提交于 2020-01-22 07:10:11
问题 I have a LinearLayout view that already contains several elements. I want to add a lot more Views to it, programmatically. And because this is inside a ScrollView , everything will be scrolled. So what I do is go through my list, and add new instances of my custom View to it. That custom view inflates a XML layout and adds a few methods. This approach works well. The problem is that it's super slow, even without any crazy code... a list with 10 items takes around 500ms to instantiate. As an

What's the quickest way to add several views to a LinearLayout?

被刻印的时光 ゝ 提交于 2020-01-22 07:09:48
问题 I have a LinearLayout view that already contains several elements. I want to add a lot more Views to it, programmatically. And because this is inside a ScrollView , everything will be scrolled. So what I do is go through my list, and add new instances of my custom View to it. That custom view inflates a XML layout and adds a few methods. This approach works well. The problem is that it's super slow, even without any crazy code... a list with 10 items takes around 500ms to instantiate. As an

How can I position a layout right above the android on-screen keyboard?

左心房为你撑大大i 提交于 2020-01-19 19:02:10
问题 See the attached photo. Twitter does it well. They have a layout, which I will call a toolbar for lack of a better term, right above the onscreen keyboard. How can I do this with my code? UPDATE: Here is my layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffffff"> <RelativeLayout android:id="@+id

How do I wrap a second text around first text title, both are in text view

北慕城南 提交于 2020-01-17 06:17:31
问题 I am trying to wrap a second text around the first text, both in relative layout and textview such that : <RelativeLayout android:id="@+id/headlineRelativeLayout" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/text1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingLeft="2dp" android:paddingRight="2dp" foo:customFont="proxima-nova-bold.ttf" android:textColor="@color/orange" android:textSize="@dimen

Divide Screen into Four Equal Parts using Relative Layout

こ雲淡風輕ζ 提交于 2020-01-15 09:54:12
问题 I currently have code that allows me to divide the screen into four equal parts, with an image button in each part. However, the code uses linear layouts which brings up the suggestion "nested weights are bad for performance". How can I make my layout using relative layouts? Below is the code, and here is a picture of the intended format <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1.0" android:orientation="horizontal" android

What is the difference between LinearLayout and FitWindowsLinearLayout?

老子叫甜甜 提交于 2020-01-15 03:43:10
问题 While creating a Layout, I cam across FitWindowsLinearLayout but can't seem to understand the difference between LinearLayout and FitWindowsLinearLayout . So, when should we use FitWindowsLinearLayout ? FitWindowsLinearLayout 回答1: First, as you can see it is annotated with @hide, which means, that it is not exposed to public API. That means that you should not use it. Secondly, to answer your question: as you can see from the implementation, it has one public method, which sets a listener:

Android- Proper positioning of layouts

為{幸葍}努か 提交于 2020-01-13 16:54:37
问题 I cant seem to properly position my layouts the way I want them to be. What my layout looks like is like this: LinearLayout LinearLayout ListView LinearLayout TextView TextView TextView Button My aim is to have it like this: Any thoughts on this please as to what Layouts i will use? Help will be appreciated 回答1: try this <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/homeTableLayout" android:layout_width="fill

Implementing OnTouchListener on LinearLayout - Android Development

十年热恋 提交于 2020-01-13 15:00:15
问题 public class UnitConverterActivity extends Activity implements OnTouchListener { /** Called when the activity is first created. */ LinearLayout mLinearLayout; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mLinearLayout = new LinearLayout(this); ImageView i = new ImageView(this); i.setImageResource(R.drawable.mainmenu); //i.setAdjustViewBounds(false); i.setScaleType(ScaleType.FIT_XY); i.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP

Android:set ImageView dynamically?

只愿长相守 提交于 2020-01-13 06:29:43
问题 I'm trying to download an image, and create an ImageView dynamically and add it to my layout, but it won't display the image. Here is my code: ImageView image = new ImageView(this); LinearLayout.LayoutParams vp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); image.setLayoutParams(vp); image.setScaleType(ImageView.ScaleType.CENTER_CROP); image.setMaxHeight(50); image.setMaxWidth(50); image.setImageDrawable(avatar); theLayout.addView(image); maybe I need to

Using Layout resources in a LiveWallpaper on Android

假如想象 提交于 2020-01-12 05:47:08
问题 When you create a LiveWallpaper in Android 2.2+ you get a canvas (or whatever the 3D equivalent is) to draw on. I'd like to draw some elements using the built-in Android UI tools rather than building everything from scratch using canvas commands or a loading a pre-rendered UI bitmap. Converting a single View to a Bitmap works fine. i.e. this works great: // For example this works: TextView view = new TextView(ctx); view.layout(0, 0, 200, 100); view.setText("test"); Bitmap b = Bitmap