Giter VIP home page Giter VIP logo

Comments (10)

ParfoisMeng avatar ParfoisMeng commented on August 20, 2024 1

@senRsl
对于你描述的场景我不是很认同。
但是右滑的功能看来倒是的确有需求,我看看什么时候有时间试一下加这个功能吧。

from slideback.

wizos avatar wizos commented on August 20, 2024

我按照 slideBackIconView 代码改写了一份可以放在右侧的view(rightSlideBackIconView),但是卡在 container.addView(rightSlideBackIconView); 这个view 无法紧贴右侧屏幕,一直在左侧。请问下能则呢么解决?

from slideback.

ParfoisMeng avatar ParfoisMeng commented on August 20, 2024

@wizos
可以将view放在右侧,目前库里还没有相关实现。虽然没明白需求(ViewPager左右滑),有时间我看看怎么加上比较合适吧。
您的实现方式思路上应该没问题。至于问题,container是一个FrameLayout,addView是默认在左上角的(x=0,y=0)。如果要放在右边,需要加margin去定位(margin_left=screenWidth-viewWidth)。

PS:个人感性上不喜欢margin属性(开发人员选项-显示布局边界,margin属性是红色的,看着很刺眼),所以我不是很推荐使用margin。但目前也想不到更好的方案,如果您需要此功能,可以试一下。

from slideback.

wizos avatar wizos commented on August 20, 2024

请问怎么加 margin 呢?我使用以下代码,但是不生效。
`
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);

lp.setMargins(screenWidth-viewWidth,0,0,0);

rightSlideBackView.setLayoutParams(lp);

container.addView(rightSlideBackView,lp);`

from slideback.

ParfoisMeng avatar ParfoisMeng commented on August 20, 2024

参考此方法

/**
* 给SlideBackIconView设置topMargin,起到定位效果
*
* @param view SlideBackIconView
* @param position 触点位置
*/
private void setSlideBackPosition(SlideBackIconView view, int position) {
// 触点位置减去SlideBackIconView一半高度即为topMargin
int topMargin = (int) (position - (view.getBackViewHeight() / 2));
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(view.getLayoutParams());
layoutParams.topMargin = topMargin;
view.setLayoutParams(layoutParams);
}

from slideback.

wizos avatar wizos commented on August 20, 2024

还是不行……

`
container.addView(rightSlideBackView);

FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(rightSlideBackView.getLayoutParams());

layoutParams.leftMargin = (int)(screenWidth - maxSlideLength);

rightSlideBackView.setLayoutParams(layoutParams);`

image

from slideback.

ParfoisMeng avatar ParfoisMeng commented on August 20, 2024

最近沉迷塞尔达难以自拔。。
不急的话,我周末抽时间看看吧。

from slideback.

wizos avatar wizos commented on August 20, 2024

哈哈,前段时间我也沉迷这个。先谢谢了。

from slideback.

ParfoisMeng avatar ParfoisMeng commented on August 20, 2024

@senRsl
在我看来,普通app、不是浏览器app,完全不需要这个功能(我也没有发现这种app),我也想不到什么应用场景(网页上右滑前进,前进哪个URL?)。
如果你有什么不同见解,请在这里回复告诉我。

from slideback.

ParfoisMeng avatar ParfoisMeng commented on August 20, 2024

@senRsl @wizos
已支持设置屏幕左右侧侧滑,请更新 1.0.5

from slideback.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.