android-layout-weight

Place buttons half in one layout parent and half in another

懵懂的女人 提交于 2019-12-11 14:49:14
问题 I have the following layout, it works fine and gives me the result. The result I want is to divide the screen into two parts and place buttons half in each part: <RelativeLayout android:layout_width="match_parent" android:layout_height="200dp" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" > <RelativeLayout

Why is my Android Scrollview not scrolling?

喜欢而已 提交于 2019-12-11 13:25:51
问题 For some reason scrolling is not getting activated. I want to have that black place cover half the screen also. But if I change that height of ScrollView to wrap content then this black space disappears. This black space will have photo thats why I need it to cover at least half. I used layout weight for it but because the pictures are dynamicly loaded I have to reserve the space. Currently in this code it reserves half of the screen but Scrool does not get activated and other items are not

Why do my EditTexts not display at all?

。_饼干妹妹 提交于 2019-12-11 03:11:36
问题 With this xml: <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="5dp"> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="25" android:text="@string/id" android:textAppearance="?android:attr/textAppearanceMedium" /> <EditText android:id="@+id/editTextID" android:layout_width="0dp" android:background="@drawable/greyframe" android:layout_weight="25" android:layout

android layout weight %

…衆ロ難τιáo~ 提交于 2019-12-11 01:39:49
问题 I am trying to messing around with the Android layout weight attributes. I want a vertical layout with "3 child layouts" The first will take 25% of the space, the second 50%, and the last 25% of the space. When I try to add to the last layout, everything just not working. What should be the weight for each of these layouts? I get the weight attributes to work fine with just 2 layouts/elements and understand how it works but when I try with 3 I get a problem. <LinearLayout android:layout_width

ListView layout_weight not working, height set to 0dp

ぐ巨炮叔叔 提交于 2019-12-10 17:16:40
问题 I'm trying to use the layout_weight attribute for testing. It works fine excpect for the ListView. I've set the height to 0dp and the weightsum. I've tried to put the ListView into a relative Layout but I get the same result. Here is my code: <?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="vertical" android:weightSum="1" > <TextView

Android: Setting the Weight parameter programmatically does the opposite of what i want

☆樱花仙子☆ 提交于 2019-12-10 03:52:14
问题 I'm having a problem with android. I'm setting the Weight parameter in Java, but it's doing exactly the oposite of what I want. Here's the code LinearLayout container = new LinearLayout(context); // some code ... container.setWeightSum(1f); View v1 = new View(context); v1.setBackgroundColor(Color.parseColor("#ff0000")); LinearLayout.LayoutParams p1 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT); p1.weight=0.1f; View v2 = new View

Android TextView does not expand to match parent

岁酱吖の 提交于 2019-12-06 07:55:35
I have a viewgroup like this image: I want to not show those texts that are empty. For example, assume that I have no tips and promo then just Notes should be visible. When I test my program Notes (displayed with red background) does not expand to fill parent although its width set to match parent. Any idea would be appreciated. Thanks. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/llNotesContainer" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/tracking_bg

How can I give my widgets' width a percentage rather than an explicit value?

痴心易碎 提交于 2019-12-06 02:50:33
Based on how XAML works, I thought I could give my android widgets a percentage value for width. After searching, I found that *theoretically," this is available via the "layout_weight" property. But using this does not produce the desired appearance. Specifically, this xml: <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="5dp"> <Spinner android:id="@+id/spinnerUPCPLU" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight=".40" android:entries="@array/delivery_upcplu_spinner"

Android: Setting the Weight parameter programmatically does the opposite of what i want

时间秒杀一切 提交于 2019-12-05 04:44:23
I'm having a problem with android. I'm setting the Weight parameter in Java, but it's doing exactly the oposite of what I want. Here's the code LinearLayout container = new LinearLayout(context); // some code ... container.setWeightSum(1f); View v1 = new View(context); v1.setBackgroundColor(Color.parseColor("#ff0000")); LinearLayout.LayoutParams p1 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT); p1.weight=0.1f; View v2 = new View(context); v2.setBackgroundColor(Color.parseColor("#000000")); LinearLayout.LayoutParams p2 = new

How do I set android:layout_columnWeight=“1” programmatically to an element in an android support v7 Gridlayout

送分小仙女□ 提交于 2019-12-04 22:16:30
I'm trying to build a GirdLayout programmatically with 2 columns and I want these columns to have equal width set at half the width of the screen. I figured out you can do this since API 21 or with the support v7 GirdLayout view. I see examples that uses android:layout_columnWeight="1" to do this. But I can not find how to do this programmatically. Can anyone help me with this matter? package com.tunify.v3.component; import java.util.ArrayList; import android.support.v7.widget.GridLayout; import android.util.DisplayMetrics; import android.util.TypedValue; import android.view.ViewGroup; import