我写了这样的xml,但如何在主要活动中调用它,需要在列表视图后显示卡片视图。在我的主要活动欢迎帖子不可见。我需要在列表视图末尾显示从我的数据库中获取的布局
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/swipe"
android:layout_width="match_parent"
android:layout_height="match_parent">
<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="com.shuan.Project.fragment.ConnectionFragment">
<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<ListView
android:id="@+id/post"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@null"
android:visibility="gone" />
<RelativeLayout
android:layout_below="@+id/post"
android:id="@+id/udyopro_post"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<android.support.v7.widget.CardView
android:id="@+id/udyopost"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/standard_margin"
android:layout_marginLeft="@dimen/standard_margin"
android:layout_marginRight="@dimen/standard_margin"
android:layout_marginTop="28dp"
app:cardBackgroundColor="#f0f0f0"
app:cardCornerRadius="@dimen/small_margin"
app:cardElevation="@dimen/small_margin">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/cmpny_logo"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_marginBottom="@dimen/small_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/standard_margin"
android:background="@drawable/job_post"
android:elevation="@dimen/standard_margin"
android:padding="2dp"
android:src="@drawable/logo" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/cmpny_logo"
android:textAppearance="?android:textAppearanceLarge"
android:text="Welcome to Udyomitra..!"
android:paddingTop="16dp"
android:paddingLeft="10dp"
android:textStyle="bold"/>
<TextView
android:id="@+id/prof"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/cmpny_logo"
android:padding="@dimen/standard_margin"
android:textAppearance="?android:textAppearanceMedium"
android:text=" Greetings of the day!! Welcome to a whole new world of opportunities. With the New Year ahead of us, Udyomitra will help you write a new story by setting higher goals in your life. We exposed you to all the vacancies in and around your native location by default. You will be following all your college mates and their working firms by default. We generate a decent quality resume for you for free. We will help you find the work you enjoy since you are best suited for it.We wish you all success!"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
</RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>
这是我的xml文件
替换&#34; @patel pinkal&#34;
建议的代码后出错 01-25 12:06:56.701 19657-19657/com.shuan.Project E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.shuan.Project, PID: 19657
java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout
at android.widget.RelativeLayout$DependencyGraph.getSortedViews(RelativeLayout.java:1895)
at android.widget.RelativeLayout.sortChildren(RelativeLayout.java:401)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:409)
at android.view.View.measure(View.java:17915)
at android.support.v4.widget.SwipeRefreshLayout.onMeasure(SwipeRefreshLayout.java:612)
at android.view.View.measure(View.java:17915)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:846)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:512)
at android.view.View.measure(View.java:17915)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:846)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:512)
at android.view.View.measure(View.java:17915)
at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1075)
at android.view.View.measure(View.java:17915)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5698)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:465)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
at android.view.View.measure(View.java:17915)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5698)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1692)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:760)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
at android.view.View.measure(View.java:17915)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5698)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:465)
at android.view.View.measure(View.java:17915)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5698)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1692)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:760)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
at android.view.View.measure(View.java:17915)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5698)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:465)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2730)
at android.view.View.measure(View.java:17915)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2412)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1414)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1638)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1292)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6598)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:800)
at android.view.Choreographer.doCallbacks(Choreographer.java:603)
at android.view.Choreographer.doFrame(Choreographer.java:572)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:786)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5649)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
答案 0 :(得分:0)
您可以使用scrollView
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
// layout content
</ScrollView>
有关详细信息,请参阅此link
希望这有帮助。
答案 1 :(得分:0)
替换此
<ListView
android:id="@+id/post"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@null"
android:visibility="gone" />
用
<ListView
android:id="@+id/post"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@null"
android:layout_above="@+id/udyopro_post"
android:visibility="gone" />
也替换此
<RelativeLayout
android:layout_below="@+id/post"
android:id="@+id/udyopro_post"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
用这个
<RelativeLayout
android:layout_alignParentBottom="true"
android:id="@+id/udyopro_post"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">