使元素成为实体?
Making an element solid?
我的意思是,我想制作一个像 html 中那样的元素。你知道,没有任何问题,它有自己的部门。但在我所有的活动中,一切似乎都集中在一个地方。我怎样才能做到这一点?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar"/>
</LinearLayout>
<FrameLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.blunderer.materialdesignlibrary.views.CardView
android:id="@+id/cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:mdl_title="CardView"
app:mdl_description="A Basic CardView"
app:mdl_normalButton="Normal"
app:mdl_highlightButton="Highlight"
app:mdl_imagePosition="none"
android:layout_margin="20dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="0dp"/>
<com.blunderer.materialdesignlibrary.views.CardView
android:id="@+id/cardview2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:mdl_title="127.0.0.1:8080"
app:mdl_description="Konum: Yerel\nPing: 0 ms"
app:mdl_imagePosition="none"
android:layout_margin="20dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="0dp"/>
</FrameLayout>
</RelativeLayout>
那是我的 xml。
问题是您正在使用相对布局作为 parent 布局,并且您没有分配孩子相对于彼此的位置。
你能做什么:-
选项 1
将相对布局替换为垂直方向的线性布局作为根布局,您会发现所有视图现在都在另一个下方对齐。您的视图看起来 'solid' 就像一个网页。
它会让您有宾至如归的感觉,因为我认为您是 Web 开发人员并且是 android.
的新手
http://www.tutorialspoint.com/android/android_linear_layout.htm
选项 2
正确的方法是分配相对于彼此的视图位置。您需要将视图放在下面或 beside 彼此 :-
选项 3
尝试在 ide 的 xml 查看器中拖放视图。此 Will 适用于演示,但不推荐用于实际项目。
我的意思是,我想制作一个像 html 中那样的元素。你知道,没有任何问题,它有自己的部门。但在我所有的活动中,一切似乎都集中在一个地方。我怎样才能做到这一点?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar"/>
</LinearLayout>
<FrameLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.blunderer.materialdesignlibrary.views.CardView
android:id="@+id/cardview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:mdl_title="CardView"
app:mdl_description="A Basic CardView"
app:mdl_normalButton="Normal"
app:mdl_highlightButton="Highlight"
app:mdl_imagePosition="none"
android:layout_margin="20dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="0dp"/>
<com.blunderer.materialdesignlibrary.views.CardView
android:id="@+id/cardview2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:mdl_title="127.0.0.1:8080"
app:mdl_description="Konum: Yerel\nPing: 0 ms"
app:mdl_imagePosition="none"
android:layout_margin="20dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="0dp"/>
</FrameLayout>
</RelativeLayout>
那是我的 xml。
问题是您正在使用相对布局作为 parent 布局,并且您没有分配孩子相对于彼此的位置。
你能做什么:-
选项 1
将相对布局替换为垂直方向的线性布局作为根布局,您会发现所有视图现在都在另一个下方对齐。您的视图看起来 'solid' 就像一个网页。 它会让您有宾至如归的感觉,因为我认为您是 Web 开发人员并且是 android.
的新手http://www.tutorialspoint.com/android/android_linear_layout.htm
选项 2
正确的方法是分配相对于彼此的视图位置。您需要将视图放在下面或 beside 彼此 :-
选项 3
尝试在 ide 的 xml 查看器中拖放视图。此 Will 适用于演示,但不推荐用于实际项目。