我在tablayout的活动中定义了view pager和tablayout,我正在显示点指示器。尽管它工作正常,但我想缩小tablayout和view pager之间的差距。
SCREENSHOT
布局文件
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="130dp"
android:layout_marginTop="5dp"
android:id="@+id/homeOffers"/>
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/indicator"
app:tabGravity="center"
app:tabIndicatorHeight="0dp"
app:tabBackground="@drawable/tab_selector"/>
</LinearLayout>
查看传呼机项目布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="130dp"
app:contentPadding="3dp"
app:cardCornerRadius="3dp"
app:cardBackgroundColor="#fff"
app:cardUseCompatPadding="true">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/offerImage"
android:scaleType="fitXY"/>
</android.support.v7.widget.CardView>
</LinearLayout>
请让我知道如何实现所需的布局。任何帮助将不胜感激。
谢谢
答案 0 :(得分:1)
像这样使用RelativeLayout-
begin
using FFTW
using DifferentialEquations
using PyPlot
end
begin
n = 512
L = 200
n2 = Int(n/2)
alpha = 2im
beta = 1im
x = range(-L/2,stop=L/2,length=n)
u0 = 0.01*(rand(ComplexF64, n) .- 0.5)
k = [0:n/2-1; 0; -n/2+1:-1] .*(2*pi/L);
k2 = k.*k
k2[n2 + 1] = (n2*(2*pi/L))^2
T = plan_fft(u0)
Ti = plan_ifft(T*u0)
LinOp = (1.0 .- k2.*(1.0 .+alpha))
Fu0 = T*u0
end
function cgle!(du, u, p, t)
LinOp, b, T, Ti = p
invu = Ti*u
du .= LinOp.*u .- T*( (1.0 .+b) .* (abs.(invu)).^2 .* invu)
end
pars = LinOp, beta, T, Ti
prob = ODEProblem(cgle!, Fu0, (0.,100.), pars)
@time u = solve(prob)
t = collect(range(0, stop=50, length=1000))
sol = zeros(eltype(u),(n, length(t)))
for it in eachindex(t)
sol[:,it] = Ti*u(t[it])
end
IM = PyPlot.imshow(abs.(sol))
cb = PyPlot.colorbar(IM, orientation="horizontal")
gcf()
然后从您的卡片视图中删除此行-
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="130dp"
android:layout_marginTop="5dp"
android:id="@+id/homeOffers"/>
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/indicator"
app:tabGravity="center"
app:tabIndicatorHeight="0dp"
app:tabBackground="@drawable/tab_selector"
android:layout_below="@id/homeOffers/>
</RelativeLayout>