您好Stackoverflow用户,
我有一个使用Ubuntu 16.04的Vagrant安装但这些行无法正确运行,因为缺少public class Texts
{
public static void setNiceAndTightWidth ( EditText editText, int maxInputLength )
{
// String of chars to test for widest char. Include all possible input chars and chars of hint, as we need to make room for hint as well.
String testChars = String.format("1234568790%s", editText.getHint().toString());
char widestChar = getWidestChar(editText, testChars);
String widestString = repeat(widestChar, maxInputLength);
float widestStringWidth = getTextWidth(editText, widestString);
int width = (int)(widestStringWidth + 0.5f);
editText.setWidth(width);
// This was an experiment but it doesn't help.
ViewGroup.LayoutParams lp = editText.getLayoutParams();
lp.width = width;
editText.setLayoutParams(lp);
}
public static char getWidestChar ( TextView textView, String testChars )
{
float width, widest = 0;
char widestChar = '\0';
// Using Paint properties of TextView, including Fontface, text size, etc.
Paint paint = new Paint( textView.getPaint() );
for ( int i = 0 ; i < testChars.length() ; i++ ) {
width = paint.measureText(testChars, i, i+1);
if ( width > widest ) {
widest = width;
widestChar = testChars.charAt(i);
}
}
return widestChar;
}
public static String repeat ( char ch, int length )
{
char[] chars = new char[length];
Arrays.fill(chars, ch);
String string = String.valueOf(chars);
return string;
}
public static float getTextWidth ( TextView textView, CharSequence text )
{
Paint paint = new Paint( textView.getPaint() );
float width = paint.measureText(text, 0, text.length());
return width;
}
}
目录。
/home/vagrant
但是我使用Ubuntu 14.04运行这个shell代码,并且没有任何错误。它可以运行上面的代码correclty。
您知道在哪里或如何安装“home / vagrant”目录?
答案 0 :(得分:0)
您的信箱附带了默认的Vagrant文件,您可以在其中看到
.jrxml
你可以查看`.vagrant.d / boxes /// Vagrantfile``下的默认Vagrantfile
您可以通过(重新)添加
强制创建默认文件夹config.vm.synced_folder '.', '/vagrant', disabled: true
在你自己的Vagrantfile中