我正在尝试添加按钮到gridview下面,但在我的情况下它不工作但在布局设计按钮是显示,当我正在运行应用程序按钮是隐形请帮助我。我需要一个按钮下面gridview我已经添加按钮以及布局中的gridview。当我在线性布局外写一个按钮代码时,它工作但是按钮看起来不正常 Screenshot of output 这是我的xml代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<!-- tools:showIn="@layout/navigation_activity_main"-->
<RelativeLayout
android:id="@+id/search_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
android:padding="@dimen/activity_horizontal_margin">
<android.support.v7.widget.SearchView
android:id="@+id/search_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/searchcorner"
app:queryHint="Search Services" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="55dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/search_layout"
android:padding="@dimen/activity_horizontal_margin"
android:text="Recommended Services"
android:textSize="15dp" />
<ViewFlipper
android:id="@+id/flipper1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:flipInterval="3000"
android:inAnimation="@android:anim/slide_in_left"
android:outAnimation="@android:anim/slide_out_right">
<ImageView
android:layout_width="match_parent"
android:layout_height="110dp"
android:layout_gravity="center_horizontal"
android:contentDescription="ImageOne"
android:src="@mipmap/banner" />
</ViewFlipper>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="230dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<GridView
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="280dp"
android:columnWidth="90dp"
android:gravity="center"
android:horizontalSpacing="1dp"
android:numColumns="3"
android:stretchMode="columnWidth"
android:verticalSpacing="1dp">
</GridView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/btnallservice"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_gravity="center"
android:background="@drawable/rounded_green"
android:ems="10"
android:gravity="center"
android:text="All Services"
android:textSize="20dp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
答案 0 :(得分:0)
在GridView中添加namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Dropbox\Client;
use Dropbox\WriteMode;
class ExpenseController extends Controller
{
public function postExpenseAdd( Request $request ){
$Client = new Client(env('DROPBOX_TOKEN'), env('DROPBOX_SECRET'));
$file = fopen(public_path('img/admin.png'), 'rb');
$size = filesize(public_path('img/admin.png'));
$dropboxFileName = '/myphoto4.png';
$Client->uploadFile($dropboxFileName,WriteMode::add(),$file, $size);
$links['share'] = $Client->createShareableLink($dropboxFileName);
$links['view'] = $Client->createTemporaryDirectLink($dropboxFileName);
print_r($links);die;
}
}
并将高度更改为android:layout_weight="1"
它可以正常工作。
编辑:
android:layout_height="match_parent"