HorizontalScrollView 隐藏其子视图
HorizontalScrollView hides its child views
每当我在 xml 文件中包含带有水平滚动视图标签的自定义 viewws 时,视图似乎消失了。
在之前的相关问题中,它被称为
"Horizontal scroll view hides its children if you set
android:layout_gravity="center_horizontal" for inner container."
<HorizontalScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="horizontal"
tools:layout_constraintTop_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="8dp"
tools:layout_constraintLeft_creator="1"
android:layout_marginBottom="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp">
<com.example.mahikanthnag.cs.views.StateProgressBar
android:id="@+id/your_state_progress_bar_id"
android:layout_width="200dp"
android:layout_height="wrap_content"
app:spb_currentStateNumber="three"
app:spb_maxStateNumber="four"
app:spb_stateBackgroundColor="#BDBDBD"
app:spb_stateForegroundColor="#009688"
app:spb_stateNumberBackgroundColor="#808080"
app:spb_stateNumberForegroundColor="#eeeeee"
app:spb_currentStateDescriptionColor="#009688"
app:spb_stateDescriptionColor="#808080"
app:spb_animateToCurrentProgressState="true"
app:spb_checkStateCompleted="true"
/>
<com.example.mahikanthnag.cs.views.StateProgressBar
android:id="@+id/your_state_progress_bar_id1"
android:layout_width="200dp"
android:layout_height="wrap_content"
app:spb_currentStateNumber="three"
app:spb_maxStateNumber="four"
app:spb_stateBackgroundColor="#BDBDBD"
app:spb_stateForegroundColor="#009688"
app:spb_stateNumberBackgroundColor="#808080"
app:spb_stateNumberForegroundColor="#eeeeee"
app:spb_currentStateDescriptionColor="#009688"
app:spb_stateDescriptionColor="#808080"
app:spb_animateToCurrentProgressState="true"
app:spb_checkStateCompleted="true"
android:layout_toRightOf="@+id/your_state_progress_bar_id"
/>
<com.example.mahikanthnag.cs.views.StateProgressBar
android:id="@+id/your_state_progress_bar_id2"
android:layout_width="200dp"
android:layout_height="wrap_content"
app:spb_currentStateNumber="three"
app:spb_maxStateNumber="four"
app:spb_stateBackgroundColor="#BDBDBD"
app:spb_stateForegroundColor="#009688"
app:spb_stateNumberBackgroundColor="#808080"
app:spb_stateNumberForegroundColor="#eeeeee"
app:spb_currentStateDescriptionColor="#009688"
app:spb_stateDescriptionColor="#808080"
app:spb_animateToCurrentProgressState="true"
app:spb_checkStateCompleted="true"
android:layout_toRightOf="@+id/your_state_progress_bar_id1"
/>
</RelativeLayout>
</HorizontalScrollView>
但就我而言,我根本没有 android:layout_gravity 属性。我该如何解决?
这是我的布局 xml 文件,我在其中添加了自定义视图
欢迎任何建议
谢谢
使用线性布局而不是如下所示的相对布局:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:scrollbars="none">
<LinearLayout
android:id="@+id/travelGallery"
android:layout_width="100dp"
android:layout_height="100dp"
android:gravity="center"
android:orientation="horizontal" >
<Your view 1/>
<Your view 2/>
<Your view n/>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
每当我在 xml 文件中包含带有水平滚动视图标签的自定义 viewws 时,视图似乎消失了。 在之前的相关问题中,它被称为
"Horizontal scroll view hides its children if you set android:layout_gravity="center_horizontal" for inner container."
<HorizontalScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scroll"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="horizontal"
tools:layout_constraintTop_creator="1"
tools:layout_constraintRight_creator="1"
tools:layout_constraintBottom_creator="1"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="8dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="8dp"
tools:layout_constraintLeft_creator="1"
android:layout_marginBottom="8dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp">
<com.example.mahikanthnag.cs.views.StateProgressBar
android:id="@+id/your_state_progress_bar_id"
android:layout_width="200dp"
android:layout_height="wrap_content"
app:spb_currentStateNumber="three"
app:spb_maxStateNumber="four"
app:spb_stateBackgroundColor="#BDBDBD"
app:spb_stateForegroundColor="#009688"
app:spb_stateNumberBackgroundColor="#808080"
app:spb_stateNumberForegroundColor="#eeeeee"
app:spb_currentStateDescriptionColor="#009688"
app:spb_stateDescriptionColor="#808080"
app:spb_animateToCurrentProgressState="true"
app:spb_checkStateCompleted="true"
/>
<com.example.mahikanthnag.cs.views.StateProgressBar
android:id="@+id/your_state_progress_bar_id1"
android:layout_width="200dp"
android:layout_height="wrap_content"
app:spb_currentStateNumber="three"
app:spb_maxStateNumber="four"
app:spb_stateBackgroundColor="#BDBDBD"
app:spb_stateForegroundColor="#009688"
app:spb_stateNumberBackgroundColor="#808080"
app:spb_stateNumberForegroundColor="#eeeeee"
app:spb_currentStateDescriptionColor="#009688"
app:spb_stateDescriptionColor="#808080"
app:spb_animateToCurrentProgressState="true"
app:spb_checkStateCompleted="true"
android:layout_toRightOf="@+id/your_state_progress_bar_id"
/>
<com.example.mahikanthnag.cs.views.StateProgressBar
android:id="@+id/your_state_progress_bar_id2"
android:layout_width="200dp"
android:layout_height="wrap_content"
app:spb_currentStateNumber="three"
app:spb_maxStateNumber="four"
app:spb_stateBackgroundColor="#BDBDBD"
app:spb_stateForegroundColor="#009688"
app:spb_stateNumberBackgroundColor="#808080"
app:spb_stateNumberForegroundColor="#eeeeee"
app:spb_currentStateDescriptionColor="#009688"
app:spb_stateDescriptionColor="#808080"
app:spb_animateToCurrentProgressState="true"
app:spb_checkStateCompleted="true"
android:layout_toRightOf="@+id/your_state_progress_bar_id1"
/>
</RelativeLayout>
</HorizontalScrollView>
但就我而言,我根本没有 android:layout_gravity 属性。我该如何解决?
这是我的布局 xml 文件,我在其中添加了自定义视图
欢迎任何建议 谢谢
使用线性布局而不是如下所示的相对布局:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:scrollbars="none">
<LinearLayout
android:id="@+id/travelGallery"
android:layout_width="100dp"
android:layout_height="100dp"
android:gravity="center"
android:orientation="horizontal" >
<Your view 1/>
<Your view 2/>
<Your view n/>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>