我正在尝试使用材质设计的图像模式来实现灵活空间。
为了做到这一点,我跟着this tutorial。
问题是,教程使用if(isset($score['score'])) { echo "pos:". $score['score'] ."\n"; }
,我还有另一个我想使用的视图,它只是一个带有相对视图的简单RecyclerView
:
ScrollView
所以我尝试用教程的布局xml替换此视图中的RecyclerView,但结果是我无法滚动视图。 我想这是因为<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:paddingRight="20dp" >
<TextView
android:id="@+id/loggedInTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/separator1"
android:layout_marginLeft="10dp"
android:layout_marginTop="15dp"
android:text="@string/profile_logged_in_with_title"
android:textSize="18sp" />
<ImageView
android:id="@+id/loggedInPlatformLogo"
android:layout_width="95dp"
android:layout_height="30dp"
android:layout_alignBottom="@+id/loggedInTitle"
android:layout_centerHorizontal="true"
android:layout_marginBottom="-4dp"
android:layout_marginLeft="30dp"
android:layout_toRightOf="@+id/loggedInTitle"
android:background="@drawable/facebook_logo"
android:gravity="center_horizontal|center_vertical" />
<View
android:id="@+id/separator2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignLeft="@+id/separator1"
android:layout_below="@+id/loggedInTitle"
android:layout_marginTop="17dp"
android:background="@android:color/darker_gray" />
<ImageView
android:id="@+id/homeIcon"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignLeft="@+id/loggedInTitle"
android:layout_below="@+id/separator2"
android:layout_marginTop="10dp"
android:background="@drawable/home_icon" />
<TextView
android:id="@+id/homeTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/homeIcon"
android:layout_marginBottom="4dp"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@+id/homeIcon"
android:text="@string/profile_home_title"
android:textSize="18sp"
android:textStyle="bold" />
<AutoCompleteTextView
android:id="@+id/homeAddressEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/homeIcon"
android:layout_below="@+id/homeIcon"
android:layout_marginTop="2dp"
android:ems="10"
android:hint="@string/profile_home_address_hint"
android:inputType="textAutoComplete"
android:textSize="16sp" />
<View
android:id="@+id/separator3"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignLeft="@+id/separator1"
android:layout_below="@+id/homeAddressEdit"
android:layout_marginTop="8dp"
android:background="@android:color/darker_gray" />
<ImageView
android:id="@+id/workIcon"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignLeft="@+id/homeIcon"
android:layout_below="@+id/separator3"
android:layout_marginTop="10dp"
android:background="@drawable/work_icon" />
<TextView
android:id="@+id/workTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/workIcon"
android:layout_marginBottom="4dp"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@+id/workIcon"
android:text="@string/profile_work_title"
android:textSize="18sp"
android:textStyle="bold" />
<AutoCompleteTextView
android:id="@+id/workAddressEdit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/workIcon"
android:layout_below="@+id/workIcon"
android:layout_marginTop="2dp"
android:ems="10"
android:hint="@string/profile_work_address_hint"
android:inputType="textAutoComplete"
android:textSize="16sp" />
<View
android:id="@+id/separator4"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignLeft="@+id/separator1"
android:layout_below="@+id/workAddressEdit"
android:layout_marginTop="8dp"
android:background="@android:color/darker_gray" />
<ImageView
android:id="@+id/privacyIcon"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignLeft="@+id/workIcon"
android:layout_below="@+id/separator4"
android:layout_marginTop="13dp"
android:background="@drawable/privacy_icon" />
<TextView
android:id="@+id/privacyTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/privacyIcon"
android:layout_marginBottom="4dp"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@+id/privacyIcon"
android:text="@string/profile_privacy_title"
android:textSize="18sp"
android:textStyle="bold" />
<Spinner
android:id="@+id/privacySpinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/privacyIcon"
android:layout_below="@+id/privacyIcon"
android:layout_marginBottom="4dp"
android:layout_marginTop="-3dp"
android:entries="@array/profile_privacy_settings"
android:prompt="@string/profile_privacy_title" />
</RelativeLayout>
</ScrollView>
与灵活空间模式不兼容。
下一次尝试尝试将上述ScrollView
布局转换为适配器以使用ScrollView
following this Android Developers example,但我不知道该怎么做,因为我太多了要组合的元素,示例包含简单的字符串数组。
我非常感谢适配器应该如何与上面的布局相匹配的示例,或者另一种更简单的解决方案(也许RecyclerView不是最佳方向),如果存在的话。
答案 0 :(得分:0)
Google提供了一个设计支持库。 试试这个网站: http://hmkcode.com/material-design-app-android-design-support-library-appcompat/