标签: android-linearlayout

如何将另一个视图膨胀为LinearLayout?

这是我的XML 2 LinearLayouts.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent">
    <LinearLayout
            android:id="@+id/ll_one"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            />
    <LinearLayout
            android:id="@+id/ll_two"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我从http://android.arnodenhond.com/components/graphview下载了GraphView .这个类扩展了View.我基本上想要初始化2个图表

String[] verlabels = new String[]{"aim", "25%", "50%", "75%", "start"};
String[] horlabels = new String[]{"this", "max"};

float[] values = new float[]{2.0f, 6.0f};
aaaGraphView graphView = new aaaGraphView(this, values, "Graph One",
        horlabels, verlabels, aaaGraphView.BAR);

float[] values2 = new float[]{1.0f, 12.0f};
aaaGraphView graphView2 = new aaaGraphView(this, values2, "Graph Two",
        horlabels, verlabels, aaaGraphView.BAR);
Run Code Online (Sandbox Code Playgroud)

然后膨胀graphViewll_one,graphView2 …

android graph android-linearlayout android-inflate layout-inflater

2
推荐指数
1
解决办法
4665
查看次数

Android如何获取LinearLayout的颜色"style ="@ android:style/ButtonBar""

我想以编程方式获得具有样式'ButtonBar'的LinearLayout的背景颜色.

<LinearLayout
    android:id="@+id/buttonBar"
    style="@android:style/ButtonBar"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >
Run Code Online (Sandbox Code Playgroud)

我试图使用LinearLayout的getBackgroundColor,但没有找到该方法.

有没有人有想法?电贺

android background colors android-linearlayout

2
推荐指数
1
解决办法
2533
查看次数

Android:自定义视图上的通胀异常

我有一个自定义视图,使用这些构造函数扩展LinearLayout:

public class CustomView extends LinearLayout {

public CustomView(Context context) {
    this(context, null);
}

public CustomView(Context context, AttributeSet attrs) {
    this(context, attrs, R.attr.customViewStyle);
}

public CustomView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    /* set custom attributes with TypedArray */
}

    /* other methods */
}
Run Code Online (Sandbox Code Playgroud)

在我的/res/values/attrs.xml中:

<attr name="customViewStyle" format="reference" />

<declare-styleable name="CustomeView">
    <attr name="value" format="integer" />
    <attr name="android:imeOptions" />
    <attr name="android:imeActionId" />
    <attr name="android:imeActionLabel" />
</declare-styleable>
Run Code Online (Sandbox Code Playgroud)

在我的/res/values/styles.xml中:

<style name="AppTheme" parent="@android:style/Theme.Black">
    <item name="android:windowBackground">@drawable/bg_dark_fiber</item>
    <item name="customViewStyle">@style/CustomViewStyle</item>
</style>

<style name="CustomViewStyle"> …
Run Code Online (Sandbox Code Playgroud)

android custom-controls nosuchmethoderror android-linearlayout inflate-exception

2
推荐指数
1
解决办法
4711
查看次数

如何在Android中的Relativelayout内部放置一个Linearlayout

我需要在relativelayout的底部放置一个线性布局,这是xml中最顶层的父布局.我怎样才能做到这一点?

请帮我.

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"
android:orientation="vertical" >
<RelativeLayout .......   <<--- this should occupy total available space
</Relativelayout
 <Linearlayout .......     <<-- this should place at bottom always with height 50dp
 </LineaLayout>
 </ReltiveLayout>
Run Code Online (Sandbox Code Playgroud)

android relativelayout android-layout android-linearlayout

2
推荐指数
1
解决办法
1万
查看次数

xmlns:android ="http://schemas.android.com/apk/res/android"此行在线性布局中标记为错误

在我的XML文件中,我做了一些LinearLayout,由于某种原因,我在网上得到了一个错误: xmlns:android="http://schemas.android.com/apk/res/android".它标有红色(错误),错误日志显示:"Unexpected namespace prefix "xmlns" found for tag LinearLayout"

有人知道这意味着什么吗?

xml android android-linearlayout

2
推荐指数
1
解决办法
1万
查看次数

Linearlayout以编程方式 - 如何设置分频器?

我正在TextViewsLinearLayout编程方式创建,我想用分隔符(只是一个简单的行)分隔它们.我无休止地搜索,我发现我可以使用.setDividerDrawable,但我不想使用外部图像.有小费吗?

android divider android-linearlayout

2
推荐指数
1
解决办法
7872
查看次数

如何将包含的布局推送到屏幕底部?

我有一个名为 footer.xml 的布局,稍后将包含在多个布局中。Footer.xml 如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/bottomMenu"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:orientation="horizontal"
    android:layout_alignParentBottom="true"
    android:background="@drawable/bg_gradation"
    android:weightSum="1" >
*** STUFF GOES HERE ***
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

Footer.xml 然后将包含在其他布局中,如下所示..

<?xml version="1.0" encoding="utf-8"?>
<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/backrepeat">

    <!-- As the main content view, the view below consumes the entire
         space available using match_parent in both …
Run Code Online (Sandbox Code Playgroud)

xml android android-layout android-linearlayout

2
推荐指数
1
解决办法
4919
查看次数

Android RelativeLayout:位于右下角的位置

正如您在附加的屏幕截图中看到的,我有一个问题是在每个列表项的右下角设置relativeLayout和相关textview的位置.

一旦文本太长并且需要2行,我在Relativelayout中的textview被剪切了..

我怎样才能解决这个问题 ?

在此输入图像描述

<?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:background="@color/gris_clair"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:background="@color/blanc" >

        <ImageView
            android:id="@+id/allannonces_image"
            android:layout_width="83dp"
            android:layout_height="90dp"
            android:scaleType="centerCrop" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp"
            android:layout_weight="1"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/allannonces_titre"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="TextView"
                android:textSize="15sp" />

            <TextView
                android:id="@+id/allannonces_prix"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="2dp"
                android:text="TextView" />

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/allannonces_categorie"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentRight="true"
                    android:layout_marginRight="10dp"
                    android:background="@drawable/bordertextview"
                    android:paddingLeft="5dp"
                    android:paddingRight="7dp"
                    android:text="TextView" />

            </RelativeLayout>

        </LinearLayout>

    </LinearLayout>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

android android-layout android-linearlayout android-relativelayout

2
推荐指数
1
解决办法
5494
查看次数

将布局保存为位图

我想将我的Linearlayout保存为bmp.

<LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/linearLayout_QrCode" >

        <Space
            android:layout_width="15dp"
            android:layout_height="match_parent"
            android:layout_gravity="center_vertical" />

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <Space
                android:layout_width="match_parent"
                android:layout_height="15dp" />

            <ImageView
                android:layout_width="185dp"
                android:layout_height="185dp"
                android:id="@+id/imageView_qrcode" />

            <Space
                android:layout_width="match_parent"
                android:layout_height="15dp" />

        </LinearLayout>

        <RelativeLayout
            android:layout_width="417dp"
            android:layout_height="match_parent" >

            <Space
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_alignParentStart="true"
                android:id="@+id/space2" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:id="@+id/textView_QrSticker_label"
                android:layout_alignParentStart="true"
                android:layout_above="@+id/space2"
                android:textStyle="bold"
                android:textSize="40sp" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:id="@+id/textView_QrSticker_serial"
                android:layout_below="@+id/space2"
                android:layout_alignParentStart="true"
                android:textSize="30sp" />
        </RelativeLayout>

    </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

因此,我使用以下代码执行此操作:

        public Bitmap viewToBitmap(View view) {
            Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
            Canvas canvas = new Canvas(bitmap); …
Run Code Online (Sandbox Code Playgroud)

android bitmap android-linearlayout

2
推荐指数
1
解决办法
1469
查看次数

约束布局准则不起作用

我正在设计一个聊天项目,其外观应类似于whatsapp风格的聊天界面,但问题是左侧约束似乎不起作用。

这是我的代码。

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.constraint.Guideline
    android:id="@+id/left_guideline"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    app:layout_constraintGuide_percent="0.20" />

<LinearLayout
    android:id="@+id/chat_bubble"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/chat_sender_bubble"
    android:orientation="vertical"
    app:layout_constraintHorizontal_bias="1.0"
    app:layout_constraintLeft_toRightOf="@id/left_guideline"
    app:layout_constraintRight_toRightOf="parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:layout_marginEnd="22dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="22dp"
        android:layout_marginStart="10dp"
        android:layout_marginTop="5dp"
        android:orientation="vertical">

        <ImageView
            android:id="@+id/sender_image"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:layout_marginBottom="5dp"
            android:layout_marginEnd="5dp"
            android:layout_marginRight="5dp"
            android:adjustViewBounds="true"
            android:background="@color/transparent"
            android:scaleType="center"
            android:src="@mipmap/ic_launcher"
            android:visibility="gone" />

        <TextView
            android:id="@+id/sender_message"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="start"
            android:layout_marginBottom="5dp"
            android:layout_marginEnd="5dp"
            android:layout_marginRight="5dp"
            android:text="This is a really long message that could cross the 
left guideline."
            android:textColor="@color/senderBubbleTextColor" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="end"
            android:layout_marginBottom="5dp"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/sender_timestamp" …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-linearlayout android-xml android-constraintlayout

2
推荐指数
1
解决办法
2473
查看次数