Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Android – 具有相同高程的两个视图并排大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有两个相同海拔高的旁观.我想要的行为是,他们不会因为他们具有相同的高度而彼此投下阴影,但是发生的是左边的视图在右边投下阴影.它们的大小不一样,所以我不能把它们放在另一个视图中,并应用于该视图.

这是预期的行为吗?有没有办法呢?

编辑:

我刚刚重新创建了更简单的视图,这里是代码.
我也注意到它有预期的行为,如果我直接在布局中的视图,不包括它,因为我在这个例子,我需要它的工作.

<LinearLayout
    xmlns:android="http://scheR_760_11845@as.android.com/apk/res/android"
    xmlns:tools="http://scheR_760_11845@as.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".MainActivity"
    android:BACkground="@android:color/holo_green_dark">

    <LinearLayout
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:BACkground="@android:color/holo_red_dark"
        android:elevation="24dp"/>

    <include layout="@layout/test"/>

</LinearLayout>

这里是包括

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://scheR_760_11845@as.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <LinearLayout
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:BACkground="@android:color/holo_red_dark"
        android:elevation="24dp"/>

</LinearLayout>

和截图:

解决方法

看到你拥有的层次结构

所以你应用了海拔1和3,这不是兄弟姐妹.显然,如果一个视图在层次结构中较高,则不应该施加阴影,而不管这些视图具有相同的高程或否.

如果你将高程应用到2而不是3,你将看不到阴影效果.

所以如果你只是将你的test.xml改为:

<LinearLayout
        xmlns:android="http://scheR_760_11845@as.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:elevation="24dp">

    <LinearLayout
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:BACkground="@android:color/holo_red_dark"/>

</LinearLayout>

你会得到这个输出

大佬总结

以上是大佬教程为你收集整理的Android – 具有相同高程的两个视图并排全部内容,希望文章能够帮你解决Android – 具有相同高程的两个视图并排所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。