一直试图改变材质的浮动动作按钮颜色,但没有成功.
<android.support.design.widget.FloatingActionButton
android:id="@+id/profile_edit_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
android:clickable="true"
android:src="@drawable/ic_mode_edit_white_24dp" />
Run Code Online (Sandbox Code Playgroud)
我试过补充一下
android:background="@color/mycolor"
Run Code Online (Sandbox Code Playgroud)
或通过代码
FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.profile_edit_fab);
fab.setBackgroundColor(Color.parseColor("#mycolor"));
Run Code Online (Sandbox Code Playgroud)
要么
fab.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#mycolor")));
Run Code Online (Sandbox Code Playgroud)
但以上都没有奏效.我也在"重复的问题"中尝试了解决方案,但它们都没有工作,按钮保持绿色并且也变成了正方形.
我想详细解答一下,谢谢.
PS知道如何添加涟漪效果也不错,也无法理解.
使用本教程实现灵活空间模式(具有折叠工具栏的模式).
我正在尝试实现与Lollipop Contacts活动类似的效果,该活动在进入活动时开始查看图像标题的唯一部分:
然后,用户可以向下滚动图像下方的布局,以便显示更多内容,直到达到最大值:
在我的应用程序中,我无法使其工作.
结果是,当进入活动时,图像标题以其最大尺寸(AppBarLayout的大小)呈现,就像上面的布局一样,并且与Lollipop Contacts活动不同,它只显示图像的一部分.
这是设置AppBarLayout高度的代码(我希望屏幕宽度为最大高度):
int widthPx = getResources().getDisplayMetrics().widthPixels;
AppBarLayout appbar = (AppBarLayout)findViewById(R.id.appbar);
appbar.setLayoutParams(new CoordinatorLayout.LayoutParams(CoordinatorLayout.LayoutParams.MATCH_PARENT, widthPx));
Run Code Online (Sandbox Code Playgroud)
这是设置RecyclerView的代码.尝试使用scrollToPosition,认为它会提升RecyclerView的视图,但它根本没有效果:
mRecyclerView = (RecyclerView) findViewById(R.id.activity_profile_bottom_recyclerview);
mRecyclerView.setHasFixedSize(true);
// use a linear layout manager
mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);
// specify an adapter (see also next example)
if(mAdapter == null){
mAdapter = new ProfileAdapter(this, user, inEditMode);
mRecyclerView.setAdapter(mAdapter);
}
mRecyclerView.scrollToPosition(mAdapter.getItemCount() - 1); // itemCount is 4
Run Code Online (Sandbox Code Playgroud)
这是布局xml:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_profile"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent" …
Run Code Online (Sandbox Code Playgroud) java android android-layout material-design android-5.0-lollipop
我正在尝试用Java实现Factory模式.我有一个名为Shape的类,Circle和Triangle扩展.问题是Shape构造函数只获得2个参数,而Circle获得3个参数,因此Triangle(我不会在代码部分显示,因为它与Circle相同).为了更好地展示它:
private interface ShapeFactory{
public Shape create(int x, int y);
}
private class CircleFactory implements ShapeFactory{
public Shape create(float radius, int x, int y){ //error
return new Circle(radius, x,y);
}
}
Run Code Online (Sandbox Code Playgroud)
任何想法如何克服这个问题?我不得在工厂内收到用户的意见(必须从外面收到).
谢谢!
我正在研究python 3.2.2.打破我的脑袋超过3个小时按键排序字典.我设法使它成为一个带有2个参数成员的排序列表,但最终不能使它成为一个排序的字典.
这就是我的想法:
myDic={10: 'b', 3:'a', 5:'c'}
sorted_list=sorted(myDic.items(), key=lambda x: x[0])
Run Code Online (Sandbox Code Playgroud)
但无论我怎么做不出这个排序列表的字典.我怎么做?谢谢!
得到以下图片视图:
<ImageView
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground"/>
Run Code Online (Sandbox Code Playgroud)
如果我没有为图像视图设置位图,则Ripple工作得很好.但是一旦我设置了这样的位图,涟漪效应就消失了:
ImageView iv=((ImageView)rootView.findViewById(R.id.header));
iv.setImageBitmap(myBitmap);
Run Code Online (Sandbox Code Playgroud)
这是我的ripple.xml:
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight">
<item android:id="@android:id/mask">
<shape android:shape="oval">
<solid android:color="?android:colorAccent" />
</shape>
</item>
</ripple>
Run Code Online (Sandbox Code Playgroud)
我猜这个位图隐藏了涟漪效应,我怎样才能让它可见?已经尝试过:
有任何想法吗?我见过Lollipop Contacts也是这样做的.
到目前为止,我已经使用以下代码片段来发送和接收JSON字符串:
static private String sendJson(String json,String url){
HttpClient httpClient = new DefaultHttpClient();
String responseString = "";
try {
HttpPost request = new HttpPost(url);
StringEntity params =new StringEntity(json, "UTF-8");
request.addHeader("content-type", "application/json");
request.setEntity(params);
HttpResponse response = httpClient.execute(request);
HttpEntity entity = response.getEntity();
responseString = EntityUtils.toString(entity, "UTF-8");
}catch (Exception ex) {
ex.printStackTrace();
// handle exception here
} finally {
httpClient.getConnectionManager().shutdown();
}
return responseString;
}
Run Code Online (Sandbox Code Playgroud)
即使json字符串包含UTF-8字符,上面的代码工作也很完美,一切正常.
出于几个原因,我不得不改变发送HTTP post请求的方式,并使用HttpURLConnection代替apache的HttpClient.这是我的代码:
static private String sendJson(String json,String url){
String responseString = "";
try {
URL m_url = new URL(url); …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用本教程实现带有图像模式的灵活空间.
一切正常.
注意AppBarLayout的高度定义是192dp.
我想改变屏幕的高度1/3,以匹配此模式的谷歌示例.
这是活动的onCreate中的代码(布局xml与教程中的完全相同):
AppBarLayout appbar = (AppBarLayout)findViewById(R.id.appbar);
float density = getResources().getDisplayMetrics().density;
float heightDp = getResources().getDisplayMetrics().heightPixels / density;
appbar.setLayoutParams(new CoordinatorLayout.LayoutParams(LayoutParams.MATCH_PARENT, Math.round(heightDp / 3)));
Run Code Online (Sandbox Code Playgroud)
但由于某种原因,结果并不是我所期待的.我根本无法使用此代码查看应用栏.(没有代码,高度显示为预期,但它来自XML,无法动态设置).
我一直试图运行Aleph One的例子来获得BOF并打开一个shell.
这是Aleph One论文:http://insecure.org/stf/smashstack.html
这是简单的C代码(几乎位于论文的一半):
char shellcode[] =
"\xeb\x2a\x5e\x89\x76\x08\xc6\x46\x07\x00\xc7\x46\x0c\x00\x00\x00"
"\x00\xb8\x0b\x00\x00\x00\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80"
"\xb8\x01\x00\x00\x00\xbb\x00\x00\x00\x00\xcd\x80\xe8\xd1\xff\xff"
"\xff\x2f\x62\x69\x6e\x2f\x73\x68\x00\x89\xec\x5d\xc3";
void main() {
int *ret;
ret = (int *)&ret + 2;
(*ret) = (int)shellcode;
}
Run Code Online (Sandbox Code Playgroud)
现在,我尝试在SSH bash中运行此程序,但没有成功.
由于运行后没有任何反应,我猜测我只是没有写回程地址,所以我使用GDB来查看ret变量和实际返回地址之间的偏移量,并意识到它是7.
为了检查自己,我尝试增加3,4,5,6中的ret,实际上,只有当我将第10行更改为:
ret = (int *)&ret + 7;
Run Code Online (Sandbox Code Playgroud)
我遇到了分段错误.
但是,我不明白为什么没有打开bash而我得到了这个错误.
PS我正在使用'logic smashthestack'SSH服务器(其中一个挑战是BOF):http://logic.smashthestack.org:88 /
谢谢你的帮助.
我创建了一个MouseMotionDetection类,该角色只是检测用户是否已将鼠标移动到屏幕上的任何位置.
为此我在我的类构造函数中创建了一个新的JFrame,其屏幕大小是不可见的,所以基本上我在整个屏幕上观察鼠标运动.
但是,我有一个奇怪的错误:
在代码的当前形式中,一旦激活此类,我只检测到一个鼠标移动而没有其他任何东西,它在此之后就会停止工作.但是,如果我将设置帧backfround的行放在注释中的0f,0f,0f,0f(透明)然后激活,整个屏幕变为灰色,我会按照我的需要跟踪所有鼠标动作(我只是可以看不到任何东西.
我真的不明白为什么会发生这种情况,没有看到相关问题,也没有在这个讨论MouseMotion事件的相关javadoc中.
这是代码:
public class MouseMotionDetection extends JPanel
implements MouseMotionListener{
public MouseMotionDetection(Region tableRegion, Observer observer){
addMouseMotionListener(this);
setBackground(new Color(0f,0f,0f,0f));
JFrame frame = new JFrame();
frame.setUndecorated(true);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
frame.setSize(screenSize);
frame.setBackground(new Color(0f,0f,0f,0f));
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setAlwaysOnTop(true);
JComponent contentPane = this;
contentPane.setOpaque(true);
frame.getContentPane().add(contentPane, BorderLayout.CENTER);
frame.setVisible(true);
}
@Override
public void mouseDragged(MouseEvent arg0) {
}
@Override
public void mouseMoved(MouseEvent arg0) {
System.out.println("mouse movement detected");
}
Run Code Online (Sandbox Code Playgroud) 过去几周我一直在学习React.
首先使用简单的React开发了一个简单的聊天,现在我开始将Redux集成到我的应用程序中.
我添加了一个简单的Action,一个匹配的Reducer(以及一个root reducer)和一个Store.然后我到达了需要使用react-redux库中的Provider的部分:
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { Router, browserHistory } from 'react-router';
import ConfigureStore from './Store/ConfigureStore';
import Routes from './Routes';
const store = ConfigureStore();
ReactDOM.render(
<Provider store={store}>
<Router history={browserHistory}
routes={Routes} />,
</Provider>,
document.getElementById('root')
);
Run Code Online (Sandbox Code Playgroud)
应用程序编译正常,但我在控制台中收到以下错误:
警告:失败的道具类型:提供
children
的类型的无效道具,预期单个ReactElement.在提供者array
Provider
和
未捕获的不变违规:React.Children.only预计会收到一个React元素子.
我正在使用React Create App作为入门套件.
完整代码可以在这里找到.
java ×7
android ×5
appbar ×1
c ×1
dictionary ×1
factory ×1
javascript ×1
json ×1
mouseevent ×1
python ×1
react-redux ×1
reactjs ×1
redux ×1
ripple ×1
security ×1
shellcode ×1
swing ×1
translucency ×1