小编And*_*eda的帖子

仅将 Recyclerview 的第一个位置设置为标题布局

我正在尝试在不使用任何库的情况下在 recyclerview 中创建自己的标题布局。我已经创建了两个布局,但现在我很困惑如何将第一个位置设置为标题,其他位置在它周围滚动。

这是我的标题布局 XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/shareLayout"
android:layout_width="185dp"
android:layout_height="135dp"
android:layout_below="@id/trendingToolbar"
android:background="@color/black">

<ImageView
    android:id="@+id/cameraShareIV"
    android:layout_width="60dp"
    android:layout_height="60dp"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="10dp"
    app:srcCompat="@drawable/camera_white" />

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/cameraShareIV"
    android:layout_centerHorizontal="true">

    <TextView
        android:id="@+id/infoTxt"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="20dp"
        android:gravity="center_horizontal"
        android:text="@string/share_pic_video"
        android:textColor="@android:color/white"
        android:textSize="13sp"
        android:textStyle="bold" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/infoTxt"
        android:layout_marginLeft="16dp"
        android:text="@string/share_timeout_txt"
        android:textColor="@color/colorPrimaryDark"
        android:textSize="11sp"
        android:textStyle="bold" />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

该布局包含一个图像视图,目前用作相机按钮。我想从图库中选择图像并围绕这个布局头填充它们。这是项目布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:minHeight="150dp">

<RelativeLayout
    android:layout_width="180dp"
    android:layout_height="wrap_content"
    android:minHeight="140dp">

    <ImageView
        android:id="@+id/trending_imageView"
        android:layout_width="match_parent"
        android:layout_height="140dp"
        tools:src="@drawable/ic_trophy"
        android:scaleType="fitXY"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="22dp"
        android:layout_below="@id/trending_imageView"
        android:background="@android:color/black"
        android:alpha="0.4"
        android:layout_marginTop="-20dp"
        android:layout_centerVertical="true"
        android:gravity="center_vertical">

        <TextView
            android:id="@+id/trending_userNameTV" …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview

1
推荐指数
1
解决办法
5453
查看次数

Reactjs:渲染中没有返回任何内容

我已经设置了一个基本的反应应用程序create-react-app并创建了我的第一个组件 但是,由于浏览器窗口中的此错误,项目无法构建或呈现:

CountDown(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.
./src/index.js
D:/ReactDev/CountDownReact/countdown/src/index.js:8
Run Code Online (Sandbox Code Playgroud)

这是我的index.js文件代码:

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import Bulma from 'bulma/css/bulma.css'
import App from './components/App/App';
import registerServiceWorker from './registerServiceWorker';

ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();
Run Code Online (Sandbox Code Playgroud)

以及App.js我导入新组件的位置:

import React, {Component} from 'react';
import './App.css';
import CountDown from '../countdown/Countdown';

class App extends Component {
    render() {
        return(
            <div className="App">
                Hello …
Run Code Online (Sandbox Code Playgroud)

reactjs react-dom

0
推荐指数
1
解决办法
1082
查看次数