mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-13 06:39:54 -04:00
Custom tab fix?
This commit is contained in:
parent
82ba01400d
commit
2037ca27e8
@ -982,18 +982,21 @@ public class VerticalTabLayout extends ScrollView {
|
||||
}
|
||||
|
||||
private LinearLayout.LayoutParams createLayoutParamsForTabs() {
|
||||
// Horizontal: WRAP_CONTENT, MATCH_PARENT
|
||||
final LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
||||
updateTabViewLayoutParams(lp);
|
||||
return lp;
|
||||
}
|
||||
|
||||
private void updateTabViewLayoutParams(LinearLayout.LayoutParams lp) {
|
||||
if (mMode == MODE_FIXED && mTabGravity == GRAVITY_FILL) {
|
||||
lp.width = 0;
|
||||
// Horizontal: width 0
|
||||
lp.height = 0;
|
||||
lp.weight = 1;
|
||||
} else {
|
||||
lp.width = LinearLayout.LayoutParams.WRAP_CONTENT;
|
||||
// Horizontal: width WRAP_CONTENT
|
||||
lp.height = LinearLayout.LayoutParams.WRAP_CONTENT;
|
||||
lp.weight = 0;
|
||||
}
|
||||
}
|
||||
@ -1006,7 +1009,10 @@ public class VerticalTabLayout extends ScrollView {
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
// If we have a MeasureSpec which allows us to decide our height, try and use the default
|
||||
// height
|
||||
|
||||
// Horizintal: idealHeight
|
||||
final int idealHeight = dpToPx(getDefaultHeight()) + getPaddingTop() + getPaddingBottom();
|
||||
// final int idealWidth = dpToPx(getDefaultHeight()) + getPaddingLeft() + getPaddingRight();
|
||||
switch (MeasureSpec.getMode(heightMeasureSpec)) {
|
||||
case MeasureSpec.AT_MOST:
|
||||
heightMeasureSpec = MeasureSpec.makeMeasureSpec(
|
||||
@ -1210,7 +1216,8 @@ public class VerticalTabLayout extends ScrollView {
|
||||
|
||||
switch (mMode) {
|
||||
case MODE_FIXED:
|
||||
mTabStrip.setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
// Horizontal: CENTER_HORIZONTAL
|
||||
mTabStrip.setGravity(Gravity.CENTER_VERTICAL);
|
||||
break;
|
||||
case MODE_SCROLLABLE:
|
||||
mTabStrip.setGravity(GravityCompat.START);
|
||||
@ -2038,6 +2045,10 @@ public class VerticalTabLayout extends ScrollView {
|
||||
if (mIndicatorLeft >= 0 && mIndicatorRight > mIndicatorLeft) {
|
||||
canvas.drawRect(mIndicatorLeft, getHeight() - mSelectedIndicatorHeight,
|
||||
mIndicatorRight, getHeight(), mSelectedIndicatorPaint);
|
||||
|
||||
// ADD: Try the VERTICAL
|
||||
canvas.drawRect(mIndicatorLeft, getWidth() - mSelectedIndicatorHeight,
|
||||
mIndicatorRight, getWidth(), mSelectedIndicatorPaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ import com.kdt.filerapi.*;
|
||||
import java.io.*;
|
||||
import java.nio.charset.*;
|
||||
import java.util.*;
|
||||
import net.kdt.pojavlaunch.launcheruiv3.*;
|
||||
import net.kdt.pojavlaunch.mcfragments.*;
|
||||
import net.kdt.pojavlaunch.prefs.*;
|
||||
import net.kdt.pojavlaunch.util.*;
|
||||
@ -40,7 +39,7 @@ public class PojavLauncherActivity extends AppCompatActivity
|
||||
private VerticalTabLayout tabLayout;
|
||||
*/
|
||||
|
||||
private PojavLauncherViewPager viewPager;
|
||||
private ViewPager viewPager;
|
||||
private VerticalTabLayout tabLayout;
|
||||
|
||||
private TextView tvVersion, tvUsernameView;
|
||||
|
@ -1,59 +0,0 @@
|
||||
// Source: https://github.com/TomazWang/TIL-today-i-learned/blob/master/Android/VerticalViewPager.md
|
||||
package net.kdt.pojavlaunch.launcheruiv3;
|
||||
|
||||
import android.content.*;
|
||||
import android.support.v4.view.*;
|
||||
import android.util.*;
|
||||
import android.view.*;
|
||||
|
||||
public class PojavLauncherViewPager extends ViewPager
|
||||
{
|
||||
public PojavLauncherViewPager(Context ctx) {
|
||||
this(ctx, null);
|
||||
}
|
||||
|
||||
public PojavLauncherViewPager(Context ctx, AttributeSet attrs) {
|
||||
super(ctx, attrs);
|
||||
setPageTransformer(true, new VerticalPageTransformer());
|
||||
}
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
|
||||
boolean interceped = super.onInterceptTouchEvent(swapXY(ev));
|
||||
swapXY(ev); // swap x,y back for other touch events.
|
||||
return interceped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
return super.onTouchEvent(swapXY(ev));
|
||||
}
|
||||
|
||||
private MotionEvent swapXY(MotionEvent ev) {
|
||||
float width = getWidth();
|
||||
float height = getHeight();
|
||||
|
||||
float newX = (ev.getY() / height) * width;
|
||||
float newY = (ev.getX() / width) * height;
|
||||
|
||||
ev.setLocation(newX, newY);
|
||||
|
||||
return ev;
|
||||
}
|
||||
|
||||
private class VerticalPageTransformer implements PageTransformer {
|
||||
@Override
|
||||
public void transformPage(View page, float position) {
|
||||
if (position < -1) {
|
||||
page.setVisibility(View.INVISIBLE);
|
||||
} else if (position <= 1) {
|
||||
page.setVisibility(View.VISIBLE);
|
||||
|
||||
page.setTranslationX(page.getWidth() * -position);
|
||||
page.setTranslationY(position * page.getHeight());
|
||||
} else {
|
||||
page.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/launchermainTabLayout"/>
|
||||
|
||||
<net.kdt.pojavlaunch.launcheruiv3.PojavLauncherViewPager
|
||||
<android.support.v4.view.ViewPager
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
|
Loading…
x
Reference in New Issue
Block a user