所以,我有这样的活动布局:
class CNode: public QObject
{
public:
CNode();
QString getName();
void setName(QString nameI);
bool getVisible ();
void setVisible (bool i);
void setEnabled(bool i);
bool getEnabled();
public slots:
void nameChanged();
void visibleChanged();
void enabledChanged();
public: //properties
Q_OBJECT
Q_PROPERTY(QString name READ getName WRITE setName)
Q_PROPERTY(bool visible READ getVisible WRITE setVisible)
Q_PROPERTY(bool enabled READ getEnabled WRITE setEnabled)
protected:
QTreeWidgetItem* nodeListItem;
QString name;
bool enabled;
bool visible; //if the node has to get rendered
};
class CNode2D: public CNode
{
public:
CNode2D();
virtual ~CNode2D();
void setPosX(float i);
float getPosX();
float getPosY();
void setPosY(float i);
float getHeight();
void setHeight(float i);
public slots:
void posXChanged();
void posYChanged();
void heightChanged();
public:
Q_OBJECT
Q_PROPERTY(float Position_X READ getPosX WRITE setPosX)
Q_PROPERTY(float Position_Y READ getPosY WRITE setPosY)
Q_PROPERTY(float height READ getHeight WRITE setHeight)
protected:
float height;
float posX;
float posY;
};
class CSprite2D: public CNode2D
{
public:
CSprite2D(int number, Ui::MainWindow *i);
~CSprite2D();
int getPosX();
int getPosY();
void compile();
private:
Ui::MainWindow *ui;
int number_sprite;
QString spriteLink;
void drawSprite();
};
现在,我需要在其中一个片段中实现聊天功能。 <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_activity_root_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/main_activity_app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/main_activity_collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/actionBarSize">
<include layout="@layout/include_toolbar" />
</android.support.design.widget.CollapsingToolbarLayout>
<LinearLayout
android:id="@+id/below_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/actionBarSize"
android:background="@color/colorPrimary"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="@+id/main_activity_sub_category_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/layout_margin_list"
android:gravity="start|center_vertical"
android:textColor="@color/white"
android:textSize="@dimen/text_bigger" />
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/main_activity_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ProgressBar
android:id="@+id/main_activity_progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
<vb.uzoni.ui.view.BottomMenuView
android:id="@+id/main_activity_bottom_menu_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom" />
</android.support.design.widget.CoordinatorLayout>
布局如下所示:
ChatFragment
但实际上,它使用 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/actionBarSize"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/single_message_recycler_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
</LinearLayout>
</LinearLayout>
作为父级,并将NestedScrollView
和EditText
推送到Button
的底部。
我想做的是下一步:
1.禁用NestedScrollView
的所有滚动
2.我不想继承NestedScrollView
的可滚动功能,因此我可以将NestedScrollView
和Button
放置在视图的底部,它们始终可见。
这怎么可能?
修改
现在片段中的EditText
出现问题:
NestedScrollView
它没有显示回收者视图,也没有执行appscrolling行为......
答案 0 :(得分:1)
无需使用NestedScrollView
。相反,你可以使用 -
<FrameLayout
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<!-- Replace your fragment in this container -->
<FrameLayout
android:id="@+id/main_activity_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ProgressBar
android:id="@+id/main_activity_progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone" />
</FrameLayout>
看起来,我删除了您的NestedScrollView
问题
答案 1 :(得分:0)
您可以尝试将NestedScrollView
放入Framelayout
容器中。并动态替换容器。
它将删除Nestedscrollview
滚动问题
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_activity_root_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main_activity_fragment_container"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<--Your contents-->
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>