- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我使用 Android Studio 创建一个新的 Android 应用程序项目时,文件 activity_main.xml
包含以下内容。 为什么 TextView
的 layout_width
和 layout_height
属性的值为 wrap_content
? 我想如果 View 是用约束布局的,layout_width
和 layout_height
应该有值 0dp
。
<?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"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
最佳答案
属性 layout_width 和 layout_height 的值完全取决于您的要求有关更多信息,请查看此链接:-
更多信息:- https://developer.android.com/reference/android/support/constraint/ConstraintLayout
关于生成的约束布局中的 Android layout_width ="match_parent"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54320295/
我正在尝试创建一个彩色圆圈并将其分配给我的 GridView 的 ImageView。 这是我的代码: ImageView ivColor; ivColor = new ImageView(MainA
我正在尝试为 ArrayAdapter 创建 View 。我就是这样做的: FrameLayout rowView = new FrameLayout(context); rowView.setBac
我想在 2 个 EditText 的右边有一个 ImageButton 我试过了 RelativeLayout:但是 ImageView layout_height="match_parent" 不起
我有一个带有 ImageButton 的布局。我现在要做的是将一个 TextView float 在那个 ImageButton 的角落。我将 ImageButton 替换为:
我第一次在互联网代码中遇到属性“Match_Parent”。在此之前,我一直在使用 Fill_Parent 和 Wrap_Content。 我想要什么 Match_parent 属性的用途是什么? 最
在我的布局文件中,我使用根 ScrollView 和子 LinearLayout。 我对此进行了搜索,但没有得到帮助。我在父 View 和 subview 中设置了 match_parent。 但
我尝试实现自定义操作栏。这是 xml: 这是Java代码: public class CustomActionBarActivity extends AppCompatActivity
我的应用程序以 android Sdk 的 v10 为目标,但具有 minSdkVersion 的 v6。默认情况下,“match_parent”属性将用于宽度或高度。我应该为 fill_parent
引入 match_parent 和弃用 fill_parent 的原因是什么,因为两者意思相同。这种变化不会妨碍向后兼容吗? 最佳答案 使用 match_parent 而不是 fill_parent
我想这应该是一个相当容易回答的问题,如果您比我更了解 XML 布局的话。在使用 match_parent layout_height 时,我似乎没有得到我认为应该得到的结果。 我有一个带有 and
android studio 2.0 beta5 我注意到,当我在工具栏中包含一个布局时,该布局的左边缘永远不会与工具栏父级的左边缘对齐,即使我已将两者都设置为 match_parent。 这是我的
我制作了带有搜索和设置图标的自定义工具栏。当我点击搜索图标时,edittext 应该与 match_parent 匹配,并且应该占据可用空间直到搜索图标。然而它并没有发生。它只是在左上角出现非常小的空
我尝试使用此 xml 代码制作自定义 View : 我用这段代码运行通知: protected void onCreate(Bundle savedInstanceState) {
我在 TableRow 中有 LinearLayout。 LinearLayout 在代码中启动,这样: LinearLayout mainRowLayout = new LinearLayout(
我的申请有问题。我有一张横跨整个屏幕 (ImageView) 的图像,其中包含以下 xml 代码: 我的问题是图像位于 imageview 本身的中心。它需要居中,如下图所示: 左边的图片是
我有一个水平线性布局,包含两个布局。我希望 right 布局与内容 (wrap_content) 一样宽。 left 布局应填充剩余空间。 我尝试在左侧布局(相对布局)上使用“match_parent
我正在尝试在 TAB 中将 Snakbar 设为 MatchParent。我所做的是: Snackbar snackbar = Snackbar .make(coordinat
我有一个简单的看法如下; 即使 LinearLayout 的高度和宽度都明确设置为匹配其父级,它也匹配 CardView 的宽度但在高度方向包裹其内容。为什
当我使用 Android Studio 创建一个新的 Android 应用程序项目时,文件 activity_main.xml 包含以下内容。 为什么 TextView 的 layout_width
我正在使用 drawable 设置 RelativeLayout 的背景,这里是 correct result第一次打开 Activity 时。 但是,当我切换到另一个 Activity (具有相同背
我是一名优秀的程序员,十分优秀!