android-linearlayout

findViewById() returns null for an inflated layout

喜欢而已 提交于 2020-01-06 04:09:05
问题 I have an Activity and its layout. Now I need to add a LinearLayout from another layout, menu_layout.xml . LayoutInflater inflater; inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.menu_layout, null); After this, findViewById() returns null. Is there is any solution for that? Note: I can't put both XML in one place, and using <include> also is not working. 回答1: Explanation When you inflate a

Android relatively out wrap_content and match_parent

梦想与她 提交于 2020-01-05 03:56:06
问题 I have an issue with a RelativeLayout. It is a custom view for a List Item. I have a RelativeLayout, it's height is set to wrap_content. Inside of it are three Linear Layouts, one of which has it's height set to wrap_content. The other two are set to match_parent as I need them to fill the parent after it has grown to accommodate the wrap_content one. The two that are supposed to grow are behind the other one (it's used for swiping, The top view when swiped moves out of the way to reveal the

Got Warning : this linearlayout layout or its framelayout parent is possibly useless

廉价感情. 提交于 2020-01-04 13:28:10
问题 <TabHost android:id="@+id/tabHost" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" > // --------------------------- Here I got warning ------------------------- <LinearLayout android:id="@+id/chat_list"

Got Warning : this linearlayout layout or its framelayout parent is possibly useless

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-04 13:26:30
问题 <TabHost android:id="@+id/tabHost" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" > // --------------------------- Here I got warning ------------------------- <LinearLayout android:id="@+id/chat_list"

Android Layout_weight

拟墨画扇 提交于 2020-01-03 21:08:15
问题 Maybe I misunderstood the layout_weight parameter but I can't get it why something like this is not working... <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:weightSum="1"> <TextView android:id="@+id/textView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="TextView" android

Android Layout_weight

北城以北 提交于 2020-01-03 21:08:05
问题 Maybe I misunderstood the layout_weight parameter but I can't get it why something like this is not working... <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" android:weightSum="1"> <TextView android:id="@+id/textView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="TextView" android

How to set margin in inflated linearlayout dynamically?

半城伤御伤魂 提交于 2020-01-03 17:09:13
问题 I have added a linearlayout in a linearlayout dynamically using this code. LinearLayout root = (LinearLayout) findViewById(R.id.root); View child = inflater.inflate(R.layout.childrow, null); root.addView(child , index++); I want to add bottom margin in childview. Can I do this dynamically? 回答1: View child = inflater.inflate(R.layout.childrow, null); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP

How to set margin in inflated linearlayout dynamically?

倖福魔咒の 提交于 2020-01-03 17:09:12
问题 I have added a linearlayout in a linearlayout dynamically using this code. LinearLayout root = (LinearLayout) findViewById(R.id.root); View child = inflater.inflate(R.layout.childrow, null); root.addView(child , index++); I want to add bottom margin in childview. Can I do this dynamically? 回答1: View child = inflater.inflate(R.layout.childrow, null); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP

Align image and text on textview

♀尐吖头ヾ 提交于 2020-01-03 04:18:35
问题 In my app, I populate a linearlayout with a text and a little icon (like a listview with a custom adapter). I need the text and the picture to have the same size. Is there a way to do that? Here's the code: LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT); LinearLayout LayoutPadre = new LinearLayout(this); TextView Tag = new TextView(this); ImageView img = new ImageView(this); Tag.setText(data); if(stato.equalsIgnoreCase(

Set gravity for LinearLayout programmatically

橙三吉。 提交于 2020-01-02 03:23:08
问题 I have followed an instruction for making new AdMob plugin for Unity. Ads show up correctly, but I have problem with bottom position. They show up at top of the screen. I have set gravity to bottom (for FrameLayout) but banner ads again show up at the top of screen. I dont have any .xml file with LinearLayout/FrameLayout tags. Here is all code: public class playads { private String adUnitID = "ca-app-pub-9578188175087140/5483276313"; private Activity activity; //Store the android main